Mark Dickinson added the comment: The code is behaving correctly. The surprise is due to the internal binary representation of Python floats, and is related to the documentation note about `round` here:
https://docs.python.org/3/library/functions.html#round > The behavior of round() for floats can be surprising: for example, > round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: > it’s a result of the fact that most decimal fractions can’t be represented > exactly as a float. ---------- nosy: +mark.dickinson resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30453> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com