[Numpy-discussion] Integer Overflow?

Jed Ludlow jed.ludlow@gmail....
Tue Jul 14 09:42:56 CDT 2009

Dave wrote:
> I got stung when taking an ordinary python integer to the power of a numpy
> integer - the result wasn't what I was expecting (see below)!

 From the results below, it seems to be okay if the base is a long. 
Note the type of the returned result in each case.  Does it seem 
inconsistent to return a numpy.float64 in one instance and a pure python 
float in another?


Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit 
(Intel)] on win32
Type "copyright", "credits" or "license" for more information.

Option: import all optional modules

 >>> import numpy as np
 >>> np.__version__
 >>> out = 10**-10
 >>> out.__class__
<type 'float'>
 >>> out
 >>> out = 10**np.int32(-10)
 >>> out.__class__
<type 'numpy.float64'>
 >>> out
 >>> out = 10L**np.int32(-10)
 >>> out.__class__
<type 'float'>
 >>> out

More information about the NumPy-Discussion mailing list