Entry
Why does 123.4+2=125.40000000000001?
Jun 22nd, 2000 04:25
unknown unknown, Ruud de Rooij
From http://www.python.org/1.6/
The repr() of floating point numbers now gives full (17-digit)
precision. This means that a number like 8.1 (which cannot be
represented exactly in binary) will show up as 8.0999999999999996 when
displayed using repr(). This shouldn't break any code but it may
confuse users, especially since the interactive shell uses repr() to
display all floating point results. Use str() or explicit precision in
string format (e.g. "%.12g" % x) to see the the more familiar, rounded
form.