[Numpy-discussion] Uint64 casting bug for MSVC builds

Jaime Fernández del Río jaime.frio at gmail.com
Wed Dec 3 12:14:16 EST 2014


On Wed, Dec 3, 2014 at 8:44 AM, Matthew Brett <matthew.brett at gmail.com>
wrote:

> Hi,
>
> I just noticed this using Christophe Gohlke's MKL builds of numpy:
>
> >>> import numpy as np
> >>> val = 2**63 + 2**62
> >>> np.float64(val)
> 1.3835058055282164e+19
> >>> np.float64(val).astype(np.uint64)
> 9223372036854775808
>

I have tried this out on Python 3 and 2, both 32 and 64 bits, and cannot
reproduce it:

Python 3.3.5 (v3.3.5:62cf4e77f785, Mar  9 2014, 10:35:05) [MSC v.1600 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.float64(2**63 + 2**62).astype(np.uint64)
13835058055282163712

Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.float64(2**63 + 2**62).astype(np.uint64)
13835058055282163712

Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.float64(2**63 + 2**62).astype(np.uint64)
13835058055282163712

Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.float64(2**63 + 2**62).astype(np.uint64)
13835058055282163712

These are all WinPython (http://winpython.sourceforge.net/) builds, which I
believe use a similar toolchain to Christophe's, including MKL.

Jaime

-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes
de dominación mundial.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141203/e5c289c6/attachment.html>


More information about the NumPy-Discussion mailing list