A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2011-November/114309.html below:

[Python-Dev] ints not overflowing into longs?

[Python-Dev] ints not overflowing into longs?Derek Shockey derek.shockey at gmail.com
Thu Nov 3 03:32:38 CET 2011
I just found an unexpected behavior and I'm wondering if it is a bug.
In my 2.7.2 interpreter on OS X, built and installed via MacPorts, it
appears that integers are not correctly overflowing into longs and
instead are yielding bizarre results. I can only reproduce this when
using the exponent operator with two ints (declaring either operand
explicitly as long prevents the behavior).

>>> 2**100
0
>>> 2**100L
1267650600228229401496703205376L

>>> 20**20
-2101438300051996672
>>> 20L**20
104857600000000000000000000L

>>> 10**20
7766279631452241920
>>> 10L**20L
100000000000000000000L

To confirm I'm not crazy, I tried in the 2.7.1 and 2.6.7 installations
included in OS X 10.7, and also a 2.7.2+ (not sure what the + is) on
an Ubuntu machine and didn't see this behavior. This looks like some
kind of truncation error, but I don't know much about the internals of
Python and have no idea what's going on. I assume since it's only in
my MacPorts installation, it must be build configuration issue that is
specific to OS X, perhaps only 10.7, or MacPorts.

Am I doing something wrong, and is there a way to fix it before I
compile? I could find any references to this problem as a known issue.

Thanks,
Derek
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4