Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Python 2.7.2 on OS X 10.8.5 behaves even more strangely. I get:

   >>> import numpy
   >>> x=0
   >>> y=numpy.int32(2*10**9)
   >>> y
   2000000000
   >>> x+=y
   >>> x
   2000000000
   >>> x+=y
   >>> x
   4000000000
   >>> x*x
   -2446744073709551616
   >>> y*y
   __main__:1: RuntimeWarning: overflow encountered in int_scalars
   -1651507200
I didn't think it was possible to get integer wraparound in Python. I guess it's because the "int32" from numpy "breaks" x, which subsequently no longer behaves like a python variable.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: