Opened 9 years ago

Closed 9 years ago

#32072 closed defect (duplicate)

Python: powers of two are screwed up starting at 2**63

Reported by: singingwolfboy@… Owned by: jyrkiwahlstedt
Priority: Normal Milestone:
Component: ports Version: 2.0.3
Keywords: Cc:
Port: python25 python27

Description (last modified by singingwolfboy@…)

$ # debugging info
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.7.2
BuildVersion:	11C74
$ uname -a
Darwin DBMBP.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
$ port installed python25 python27
The following ports are currently installed:
  python25 @2.5.6_2 (active)
  python27 @2.7.2_2+ucs4 (active)
$ # testing powers of two with system pythons
$ /usr/bin/python2.5 -c "print 2**62"
4611686018427387904
$ /usr/bin/python2.5 -c "print 2**63"
9223372036854775808
$ /usr/bin/python2.5 -c "print 2**64"
18446744073709551616
$ /usr/bin/python2.5 -c "print 2**65"
36893488147419103232
$ /usr/bin/python2.6 -c "print 2**62"
4611686018427387904
$ /usr/bin/python2.6 -c "print 2**63"
9223372036854775808
$ /usr/bin/python2.6 -c "print 2**64"
18446744073709551616
$ /usr/bin/python2.6 -c "print 2**65"
36893488147419103232
$ /usr/bin/python2.7 -c "print 2**62"
4611686018427387904
$ /usr/bin/python2.7 -c "print 2**63"
9223372036854775808
$ /usr/bin/python2.7 -c "print 2**64"
18446744073709551616
$ /usr/bin/python2.7 -c "print 2**65"
36893488147419103232
$ ####### WEIRDNESS BEGINS HERE ########
$ # testing powers of two with Macports pythons
$ /opt/local/bin/python2.5 -c "print 2**62"
4611686018427387904
$ /opt/local/bin/python2.5 -c "print 2**63"
-9223372036854775808
$ /opt/local/bin/python2.5 -c "print 2**64"
0
$ /opt/local/bin/python2.5 -c "print 2**65"
0
$ /opt/local/bin/python2.7 -c "print 2**62"
4611686018427387904
$ /opt/local/bin/python2.7 -c "print 2**63"
-9223372036854775808
$ /opt/local/bin/python2.7 -c "print 2**64"
0
$ /opt/local/bin/python2.7 -c "print 2**65"
0
$ # I have not tested Macports python2.4 or python2.6, but I bet it's the same
$ 

Change History (5)

comment:1 Changed 9 years ago by singingwolfboy@…

Description: modified (diff)

comment:2 Changed 9 years ago by mf2k (Frank Schima)

Keywords: python removed

I cannot reproduce this issue on python26.

In [2]: 2**62
Out[2]: 4611686018427387904

In [3]: 2**63
Out[3]: 9223372036854775808L

In [4]: 2**64
Out[4]: 18446744073709551616L

In [5]: 2**65
Out[5]: 36893488147419103232L

In [6]: 2**66
Out[6]: 73786976294838206464L

In [7]: 2**67
Out[7]: 147573952589676412928L

comment:3 Changed 9 years ago by ryandesign (Ryan Schmidt)

Unable to reproduce issue on Snow Leopard:

$ sw_vers; for v in 4 5 6 7; do port -vq installed python2${v}; for n in 62 63 64 65; do /opt/local/bin/python2.${v} -c "print 2**${n}"; done; done
ProductName:	Mac OS X
ProductVersion:	10.6.8
BuildVersion:	10K549
  python24 @2.4.6_9+universal (active) platform='darwin 10' archs='i386 x86_64'
4611686018427387904
9223372036854775808
18446744073709551616
36893488147419103232
  python25 @2.5.6_2+universal (active) platform='darwin 10' archs='i386 x86_64'
4611686018427387904
9223372036854775808
18446744073709551616
36893488147419103232
  python26 @2.6.7_2+universal (active) platform='darwin 10' archs='i386 x86_64'
4611686018427387904
9223372036854775808
18446744073709551616
36893488147419103232
  python27 @2.7.2_2+universal (active) platform='darwin 10' archs='i386 x86_64'
4611686018427387904
9223372036854775808
18446744073709551616
36893488147419103232

comment:4 Changed 9 years ago by ned-deily (Ned Deily)

See http://bugs.python.org/issue11149. If you are compiling with clang, you'll probably need to back port the fix to add -fwrapv.

comment:5 Changed 9 years ago by jmroot (Joshua Root)

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.