[Numpy-discussion] Weird clipping when astype(int) used on large numbers

Tony S Yu tonyyu@MIT....
Fri Oct 17 14:27:58 CDT 2008

I ran into this weird behavior with astype(int)

In [57]: a = np.array(1E13)

In [58]: a.astype(int)

Out[58]: array(-2147483648)

I understand why large numbers need to be clipped when converting to  
int (although I would have expected some sort of warning), but I'm  
puzzled by the negative value. Shouldn't the above code clip the value  
to the max positive int (2147483647)... and maybe issue a warning?


P.S. In case this is a problem with my install:
OS X 10.5.5
Python 2.5.1
Numpy 1.2.0

More information about the Numpy-discussion mailing list