[issue5118] '%.2f' % 2.545 doesn't round correctly

Mark Dickinson report at bugs.python.org
Sat Jan 31 16:36:03 CET 2009


Mark Dickinson <dickinsm at gmail.com> added the comment:

> So you might want to reopen the bug. But either way I don't consider
> this bug as really serious either.

I don't understand.  As far as I can see '%.2f' % 2.545 is returning
the correct result: there is no bug here, so no need to reopen. '%.2f' 
should *not* return 2.55;  it should return 2.54, which is exactly what it 
does.  round(2.545, 2) should also return 2.54, but returns 2.55 instead;  
issue 1869 is already open for this.

You're correct that the float formatting doesn't use round:  it does 
whatever the platform C library's sprintf does.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5118>
_______________________________________


More information about the Python-bugs-list mailing list