[Pythonmac-SIG] round() not consistent?
israel at uandmedance.com
israel at uandmedance.com
Fri May 28 14:41:29 EDT 2004
hello everyone..
I've been playing around with generating some random numbers with
random.random and then rounding them off to two decimal points with
round() but for some reason this doesn't always work.
here is a sample session
'''
>>> round(random.random(),2)
0.65000000000000002
>>> round(random.random(),2)
0.57999999999999996
>>> round(random.random(),2)
0.5
>>> round(random.random(),2)
0.63
>>> round(random.random(),2)
0.95999999999999996
>>> round(random.random(),2)
0.42999999999999999
>>> round(random.random(),2)
0.10000000000000001
>>> round(random.random(),2)
0.54000000000000004
>>> round(random.random(),2)
0.81999999999999995
>>> round(random.random(),2)
0.87
>>> round(random.random(),2)
0.56999999999999995
'''
Am I just not understanding how things work here?
~Israel~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 883 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20040528/f3e29208/attachment.bin
More information about the Pythonmac-SIG
mailing list