"Martin v. Loewis" <mar...@v.loewis.de> writes: >> Type "help", "copyright", "credits" or "license" for more information. >>>>> 9.95 >> 9.9499999999999993 >>>>> "%.16g" % 9.95 >> '9.949999999999999' >>>>> round(9.95, 1) >> 10.0 >> >> So it seems that Python is going out of its way to intuitively round >> 9.95, while the repr retains the unnecessary digits. > > The 2.6 result is simply incorrect. [...] > Yes. It's a bug fix described in "What's new in Python 2.7" thus:
That makes sense, thanks. Even within Python 2.6, rounding with different methods could produce inconsistent results: >>> round(9.95, 1) 10.0 >>> '%.1f' % 9.95 '9.9' -- http://mail.python.org/mailman/listinfo/python-list