Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Integer behaviour in Python 2.6.4

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


sturla at molden

Nov 1, 2009, 7:22 PM

Post #1 of 3 (252 views)
Permalink
Integer behaviour in Python 2.6.4

Why does this happen?

>>> type(2**31-1)
<type 'long'>

It seems to have broken NumPy's RNG on Win32.






_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


curt at hagenlocher

Nov 1, 2009, 7:49 PM

Post #2 of 3 (236 views)
Permalink
Re: Integer behaviour in Python 2.6.4 [In reply to]

On Sun, Nov 1, 2009 at 8:22 PM, Sturla Molden <sturla [at] molden> wrote:
>
> Why does this happen?
>
> >>> type(2**31-1)
> <type 'long'>

Does that not happen on non-Windows platforms? 2**31 can't be
represented as a 32-bit signed integer, so it's automatically promoted
to a long.

--
Curt Hagenlocher
curt [at] hagenlocher
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


sturla at molden

Nov 1, 2009, 8:21 PM

Post #3 of 3 (235 views)
Permalink
Re: Integer behaviour in Python 2.6.4 [In reply to]

Curt Hagenlocher skrev:
> Does that not happen on non-Windows platforms? 2**31 can't be
> represented as a 32-bit signed integer, so it's automatically promoted
> to a long.
>
>
Yes you are right.

I've now traced down the problem to an integer overflow in NumPy.

It seems to have this Pyrex code:

cdef long lo, hi, diff
[...]
diff = hi - lo - 1

:-D


Sturla


_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.