[Python-Dev] math.hypot, complex.__abs__, and documentation
Steven D'Aprano
steve at pearwood.info
Wed Feb 17 13:22:12 CET 2010
On Wed, 17 Feb 2010 10:06:01 am Mark Dickinson wrote:
> On Tue, Feb 16, 2010 at 10:46 PM, Steven D'Aprano
> <steve at pearwood.info>
>
> > What's the justification for that convention? It seems wrong to me.
>
> It's difficult to do better than to point to Kahan's writings. See
>
> http://www.eecs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF
Well, who am I to question Kahan?
I guess if you interpret nan as "indeterminate", than hypot(inf, nan)
should be inf; but if you interpret it as "not a number", then it
should be nan. Since NANs can be both, I guess we're stuck with one or
the other. So I'm satisfied that there's a good reason for the
behaviour, even if I'm not 100% convinced it's the best reason.
On a related note, why the distinction here?
>>> inf*inf
inf
>>> inf**2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: (34, 'Numerical result out of range')
--
Steven D'Aprano
More information about the Python-Dev
mailing list