Numerics, NaNs, IEEE 754 and C99

Gary Herron gherron at
Wed Jun 14 18:28:23 CEST 2006

Christophe wrote:
> Grant Edwards a écrit :
>> 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.
Sorry, but this is not true.

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.

Gary Herron

More information about the Python-list mailing list