Numerics, NaNs, IEEE 754 and C99

Grant Edwards grante at visi.com
Wed Jun 14 19:29:52 CEST 2006


On 2006-06-14, Christophe <chris.cavalaria at free.fr> wrote:

>>>>The division by zero trap is really annoying.  In my world the
>>>>right thing to do is to return Inf.
>>>
>>>Your world is flawed then, this is a big mistake. NaN is the
>>>only aceptable return value for a division by zero.
>> 
>> You're probably right if you're talking about math, but I'm not
>> doing math.  I'm doing engineering.  In all of the situations
>> I've ever encountered, Inf was a much better choice.
>
> You should have been more precise then : "In my ideal world, when 
> dividing a non zero value by a zero value, the result should be +Inf or 
> -Inf according the the sign rules"

True.  I've been dealing with IEEE 754 so long that I assume
things like that go without saying.

> On that point, you should also note that +0 and -0 are sometimes 
> considered two different floating point numbers in Python :)

Different but equal.

[Don't tell the Supreme Court.]

-- 
Grant Edwards                   grante             Yow!  I just had a NOSE
                                  at               JOB!!
                               visi.com            



More information about the Python-list mailing list