[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?
Jed
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__
'1.3.0'
>>> out = 10**-10
>>> out.__class__
<type 'float'>
>>> out
1e-010
>>> out = 10**np.int32(-10)
>>> out.__class__
<type 'numpy.float64'>
>>> out
7.0918695992859933e-010
>>> out = 10L**np.int32(-10)
>>> out.__class__
<type 'float'>
>>> out
1e-010
>>>
More information about the NumPy-Discussion
mailing list