Rounding Bug in Python 2.0! - ugh

Gordon Williams g_will at cyberus.ca
Tue Oct 31 16:10:20 EST 2000


When I switched from python 1.5.2 to 2.0 final I had a surprise in some code
that was working previously.

It comes down to:

>>> x=3.8999999999999999
>>> round(x,3)
3.8999999999999999
>>>

>>> x=3.123456
>>> round(x,3)
3.1230000000000002

Someone is going to start talking about machine round off errors, but this
is a BIG UGH!!
It is not what is intuitively expected.  Can we go back to the good old days
when 1.5.2 lied to us and gave us the answer that we expect and need!!

Gordon Williams






More information about the Python-list mailing list