This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients adelsonllima, joernheissler, mark.dickinson
Date 2019-12-23.15:39:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1577115584.61.0.518009540188.issue39124@roundup.psfhosted.org>
In-reply-to
Content
@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.
History
Date User Action Args
2019-12-23 15:39:44mark.dickinsonsetrecipients: + mark.dickinson, joernheissler, adelsonllima
2019-12-23 15:39:44mark.dickinsonsetmessageid: <1577115584.61.0.518009540188.issue39124@roundup.psfhosted.org>
2019-12-23 15:39:44mark.dickinsonlinkissue39124 messages
2019-12-23 15:39:44mark.dickinsoncreate