Can't exponentiate zero in NumPy

Tim Peters tim.one at comcast.net
Mon Sep 9 14:22:49 EDT 2002


[Rick Muller]
> Turns out it appears to be a more general problem than I thought.
>
>     1e-310 ** 2
>
> Works on RH linux/1.5.2, overflows on RH linux 2.2
>
>     pow(1e-310, 2)
>
> Works on linux 1.5.2, overflows on linux 2.2
>
>     import math
>     math.pow(1e-310, 2)
>
> Works on linux 1.5.2, works on linux 2.2 (??!)
>
>     1e-310 ** 2.1
>
> Works on linux 1.5.2, fails on linux 2.2
>
>     pow(1e-310, 2.1)
>
> Works on linux 1.5.2, fails on linux 2.2
>
>     math.pow(1e-310, 2.1)
>
> Works on linux 1.5.2, works on linux 2.2
> > In addition, exactly which version of Python are you using
> (2.0, 2.1, 2.1.1,
> > 2.1.2, 2.1.3, 2.2, 2.2.1, ...)?
>
> These are the standard python/python2 distributed with RedHat Linux 7.3.
>
> "Works" means returns 0.0
> "Fails" means raises an OverflowError
>
> Can someone suggest a decent workaround?

Upgrade to Python 2.2.1, or downgrade to an older version of glibc.  glibc
changed its errno behavior in a way that nobody noticed before 2.2 final was
released.  While I've never seen the problem myself, I fixed it <wink>, and
many people reported that this class of problem is indeed fixed in 2.2.1
without backing off to an older version of glibc.





More information about the Python-list mailing list