python 3.44 float addition bug?

FraserL fraser.long+usenet at NOSPAMgmail.com
Fri Jun 20 20:57:19 EDT 2014


I think I found a strange bug in python 3.4.1, 

fresh install of

 https://www.python.org/ftp/python/3.4.1/python-3.4.1.amd64.msi 

and a fresh install of 
https://www.python.org/ftp/python/2.7.7/python-2.7.7.amd64.msi
to compare it to.

#test code
z = 0.01
p = 0.0
for x, y in enumerate(range(1, 20)):
    p += z
    print(p)
#end 


3.4.1 output:

0.01
0.02
0.03
0.04
0.05
0.060000000000000005
0.07
0.08
0.09
0.09999999999999999
0.10999999999999999
0.11999999999999998
0.12999999999999998
0.13999999999999999
0.15
0.16
0.17
0.18000000000000002
0.19000000000000003


2.7.7 output:

0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.1
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19


I'm not hugely accustomed to Python, but this seems crazy to me.



More information about the Python-list mailing list