[Python-Dev] ints not overflowing into longs? (original) (raw)
Derek Shockey derek.shockey at gmail.com
Thu Nov 3 03:32:38 CET 2011
- Previous message: [Python-Dev] Unexpected behaviour in compileall
- Next message: [Python-Dev] ints not overflowing into longs?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] Unexpected behaviour in compileall
- Next message: [Python-Dev] ints not overflowing into longs?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]