No subject

Thu Nov 16 16:52:29 CST 2006

     The exp functions return HUGE_VAL when the correct value would overflow,
     and return zero if the correct value would underflow. The -lm and -lmx
     versions set the value of errno to ERANGE for both underflow and

Since the Python math module sees errno set after the call to exp, it
raises an exception.

Whereas on Linux, exp(-very big number) simply returns 0 and does not
set errno.

On the one hand, Python's behavior makes sense because it simply
reflects the behavior of the system math libraries.  On the other
hand, these kinds of differences make it hard to write portable code -
you could test on Linux and think everything is OK, then run on IRIX
and get exceptions.  Maybe that's just the way life is when you are
using floating-point math... Tim Peters may have more to say on this
topic <exp(-900)wink>

More information about the Numpy-discussion mailing list