Numerics, NaNs, IEEE 754 and C99

Grant Edwards grante at visi.com
Wed Jun 14 19:38:14 EDT 2006


On 2006-06-14, Nick Maclaren <nmm1 at cus.cam.ac.uk> wrote:
>
> In article <mailman.7040.1150302496.27775.python-list at python.org>,
> Gary Herron <gherron at islandtraining.com> writes:
>|> 
>|> The IEEE standard specifies (plus or minus) infinity as the result of
>|> division by zero.  This makes sense since such is the limit of division
>|> by a quantity that goes to zero.  The IEEE standard then goes on to
>|> define reasonable results for arithmetic between infinities and real
>|> values.  The production of, and arithmetic on, infinities is a choice
>|> that any application may want allow or not.
>
> The mistake you have made (and it IS a mistake) is in assuming
> that the denominator approaches zero from the direction
> indicated by its sign.

I assume the "you" in that sentence refers to the IEEE FP
standards group.  I just try to follow the standard, but I have
found that the behavior required by the IEEE standard is
generally what works best for my applications.

> There are many reasons why it is likely to not be, but let's give only
> two:
>
>     It may be a true zero - i.e. a count that is genuinely zero, or
> the result of subtracting a number from itself.

I do real-world engineering stuff with measured physical
quatities.  There generally is no such thing as "true zero".

> I fully agree that infinity arithmetic is fairly well-defined for
> most operations, but it most definitely is not in this case.  It should
> be reserved for when the operations have overflowed.

All I can say is that 1/0 => Inf sure seems to work well for
me.

-- 
Grant Edwards                   grante             Yow!  World War Three can
                                  at               be averted by adherence
                               visi.com            to a strictly enforced
                                                   dress code!



More information about the Python-list mailing list