Author vstinner
Recipients belopolsky, drj, mark.dickinson, vstinner
Date 2008-12-09.13:33:40
SpamBayes Score 0.0116163
Marked as misclassified No
Message-id <1228829621.62.0.773870975195.issue3166@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2008-12-09 13:33:41vstinnersetrecipients: + vstinner, mark.dickinson, belopolsky, drj
2008-12-09 13:33:41vstinnersetmessageid: <1228829621.62.0.773870975195.issue3166@psf.upfronthosting.co.za>
2008-12-09 13:33:41vstinnerlinkissue3166 messages
2008-12-09 13:33:40vstinnercreate