[Numpy-discussion] Integer type casting and OverflowError

Robert Kern robert.kern at gmail.com
Thu May 9 07:24:37 EDT 2013

On Thu, May 9, 2013 at 11:50 AM, Pauli Virtanen <pav at iki.fi> wrote:
> 09.05.2013 13:21, Robert Kern kirjoitti:
>> With master numpy (and back to 1.6.1, at least):
>> [~]
>> |1> np.int32(3054212286)
>> -1240755010
>> It seems like at one time, this used to raise an OverflowError. We can
>> see this in at least one place in scipy:
> It actually still raises an overflowerror if the integer is too big to
> fit into int64 (or maybe into int32 on 32-bit systems). The behavior is
> the same as in Numpy 1.2.0, so it has perhaps been like this forever.
> So most likely, the code in Scipy was correct only for 32-bit systems.

Which does not surprise me in the slightest.

Robert Kern

More information about the NumPy-Discussion mailing list