Comment 5 for bug 882036

Revision history for this message
Marco Dieckhoff (dieck) wrote : Re: rounding error

That's not a python bug, it is a ever-present problem when dealing with float values, in every programming language.

As all information is, floats are represented as bits. As you have a fixed amount of bits in a float value, you have a finite number of possible representations, compared to infinite numbers and decimals in the real world numbers.
As described in http://en.wikipedia.org/wiki/IEEE_754-2008, in order to allow for a maximum of representable values, rounding issues can apply:

round() is a test for >= 0.5 (or later decimals, depending on implementation)

But 2.675 is represented as a bit setting that is actually 2.67499999...
So the test for >= fails.

compare http://docs.python.org/tutorial/floatingpoint.html
That is also mentioned in the accounting mail linked above.