by mike00632 · 7y ago · 0 comments
And floats are really a whole other beast than fractions or naturals or real numbers. As I wrote earlier - the "+" operator isn't associative. Python snippet:
def before():
x = 0.0
x += 1.0
for i in xrange(1000):
x += 1e-17
return x
def after():
x = 0.0
for i in xrange(1000):
x += 1e-17
x += 1.0
return x
print before() == 1.0
print after() == 1.0
Will print: True
False