[Numpy-discussion] RE: Python 2.2 seriously crippled for numerical computation?

Skip Montanaro skip at pobox.com
Sun Mar 3 14:02:55 EST 2002


    Brad> This also happens on Win2k with Python 2.2
    Brad> P:\PUBLIC\DEMOS\WSOCK>python
    Brad> Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
    Brad> Type "help", "copyright", "credits" or "license" for more information.
    >>>> 1e-200**2
    Brad> 0.0
    >>>> 1e-200
    Brad> 9.9999999999999998e-201
    >>>> 

I believe your executable is working properly.  The exponent range for IEEE
floats is -308 ... + 308.  1e-200 is thus distinct from zero, but when you
square it (1e-200**2), it's not.  The problem people are having is that
instead of silently underflowing to zero as you demonstrated, it's raising
an OverflowError.  This appears to be because glibc's pow() implementation
isn't silently returning 0.0, but also setting errno to ERANGE.

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)




More information about the Python-list mailing list