[SciPy-dev] interesting floating point discussion

Sébastien Boisgérault boisgera at isia.cma.fr
Mon May 2 09:01:59 CDT 2005

Alan G Isaac wrote:

>It's Java focused, but more generally applicable.
>I have no idea how Python has responded
>to these issues.  A pointer to an accessible
>discussion would be welcome.
The floating-point context in Python is IMHO far
worse than in Java, principally because:

    - the standard "nostop" IEEE 754 policy is
not the default : 1.0/0.0 raises an exception
and it should not (according to the standard).

    - any special-value (0+, 0-, NaN, Inf, etc.)
handling is *fully* platform dependent. Your
platform is determined by your OS, but also by
your python version, compilation options, etc.

- Try a search on comp.lang.python with the keywords
"Tim Peters floating point IEEE 754", you'll end
up with some very interesting threads ...

Tim Peters is probably one of the best Python
experts on the floating-point theme.

- The main attempt to "fix" some of theses issues
(allow or disallow trap handling, etc) was the
fpectl module of the standard library. It is
now considered dangerous because it has not been
actively maintained. It may even not be installed
on your Python platform, given that the python
install script had forgotten to mention it ! The
omission was dicovered only recently ...

- You may also have a look at the fpconst module ...

- And recently, try the "marshal/unmarshal" thread
on python-dev.

- Mmmmm, don't forget the Decimal module. It is
pure python and therefore slow, but otherwise far
better than the *binary* floating-point stuff.
Too bad I am not an accountant ;)


Sébastien Boisgérault

More information about the Scipy-dev mailing list