python 2.3.4 for windows: float("NaN") throws exception

Tim Peters tim.peters at
Thu Jan 13 14:04:52 EST 2005

[beliavsky at]
> C99 and Fortran 2003 have IEEE arithmetic.

Not that simple (e.g., C99 doesn't *require* it; but it has a pile of
specified IEEE behaviors a conforming C99 compiler can choose to
support (or not), along with a preprocessor symbol those that do so
choose can #define to advertise that decision).

> If CPython could be compiled with a C99 compiler, would it
> also have IEEE arithmetic?

Fully define "have IEEE arithmetic".  Not that simple either.  Even on
Windows using Microsoft's C89 compiler, Python's float + - * and /
meet the 754 standard provided you're running on a Pentium or AMD
chip.  The IEEE standard says nothing about how a 754-conforming
implementation has to spell infinities or NaNs in string<->float
conversions, so that MS produces -1.#IND for a NaN doesn't oppose the
754 standard.

> Do Python number-crunchers think this is important?

Some do, some don't.  The only contributors motivated enough to "do
something about it" gave us Python's fpectl module, which is aimed
mostly at making it look like 754 gimmicks don't exist (fiddling the C
runtime system so that operations that try to produce a NaN or
infinity from finite operands raise exceptions instead).

More information about the Python-list mailing list