don't NaN & infinities hide FP errors

Gandalf gandalf at geochemsource.com
Wed Nov 17 06:56:06 EST 2004


> Just try it. 1./0. raises a ZeroDivisionError, math.log(0) raises a
> math range error, and math.log(-1) yields nan. 

This is not true. On UNIX systems, math.log(-1) will be NaN.
On a Windows system, math.log(-1) will raise this:

ValueError: math domain error

math.log(0) will raise the same on both:

OverflowError: math range error

I do not have a clue about MACs and other OSes.

I wonder why it is this way? Python under Windows and UNIX is different,
even when the architecture is the same. (i386). Is it because of the OS?
Isn't it possible to implement floating point arithmetic with assembler 
code,
and use that instead of the built-in floating point arithmetic of the C 
compiler
under Windows? Clearly, the hardware is capable of using NaN and Inf;
I believe that Python should work the same way on any system, if there is a
way to do that.

  Laci 2.0






More information about the Python-list mailing list