Message77412
Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40)
>>> reduce(lambda x,y: x*32768.0 + y, [256, 0, 0, 1, 32767])
2.9514790517935283e+20
>>> float(295147905179352891391L)
2.9514790517935289e+20
Python 2.7a0 (trunk:67679M, Dec 9 2008, 14:29:12)
>>> reduce(lambda x,y: x*32768.0 + y, [256, 0, 0, 1, 32767])
2.9514790517935283e+20
>>> float(295147905179352891391L)
2.9514790517935283e+20
Python 3.1a0 (py3k:67652M, Dec 9 2008, 13:08:19)
>>> float(295147905179352891391)
2.9514790517935283e+20
>>> digits=[256, 0, 0, 1, 32767]; x=0
>>> for d in digits:
... x*=32768.0
... x+= d
...
>>> x
2.9514790517935283e+20
All results are the same, except float(295147905179352891391L) in
Python 2.5!? Python 2.5 rounds correctly:
Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40)
>>> x=295147905179352891391L
>>> long(float(long(x))) - x
1L |
|
Date |
User |
Action |
Args |
2008-12-09 13:33:41 | vstinner | set | recipients:
+ vstinner, mark.dickinson, belopolsky, drj |
2008-12-09 13:33:41 | vstinner | set | messageid: <1228829621.62.0.773870975195.issue3166@psf.upfronthosting.co.za> |
2008-12-09 13:33:41 | vstinner | link | issue3166 messages |
2008-12-09 13:33:40 | vstinner | create | |
|