Portably generating infinity and NaN
Michael Hoffman
cam.ac.uk at mh391.invalid
Thu Apr 12 15:07:12 EDT 2007
What's the best way to portably generate binary floating point infinity
and NaNs? I only know two solutions:
1. Using the fpconst module proposed in IEEE 754, which I believe shifts
bits around.
2. Using an extension module (for example, numarray.ieeespecial will do it).
I thought of using float(Decimal("nan")), but apparently
Decimal.__float__(self) is float(str(self)), which isn't portable.
--
Michael Hoffman
More information about the Python-list
mailing list