[Numpy-discussion] Integer type casting and OverflowError

Pauli Virtanen pav at iki.fi
Thu May 9 06:50:28 EDT 2013


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.

-- 
Pauli Virtanen





More information about the NumPy-Discussion mailing list