Mark Dickinson <dicki...@gmail.com> added the comment:

@adelsonllima: Take a look at the documentation that I linked to for the round 
function, and in particular this note:

"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. See Floating Point Arithmetic: Issues and Limitations for 
more information."

As Jörn Heissler observed, the issue here is that the numeric literal 9.925 in 
the source gets turned into a float whose exact value is just slightly larger 
than 9.925 (because 9.925 can't be exactly represented in the IEEE 754 binary64 
floating-point format that your machine is almost certainly using). So because 
it's a touch larger than 9.925, it rounds up when rounding to two decimal 
places.

Closing again here: believe it or not, round is working as designed here.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39124>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to