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 serhiy.storchaka
Recipients Nathan.Goldbaum, ammar2, mark.dickinson, serhiy.storchaka, steven.daprano, tim.peters
Date 2018-01-13.00:07:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1515802068.13.0.467229070634.issue32543@psf.upfronthosting.co.za>
In-reply-to
Content
This is the result of multiple roundings.

0.9 and 0.1 can't be represented exactly as floats. They are approximated by binary fractions.

>>> from fractions import Fraction
>>> Fraction(0.9)
Fraction(8106479329266893, 9007199254740992)
>>> Fraction(0.1)
Fraction(3602879701896397, 36028797018963968)

The result of the division of these fractions can't be represented as a float too.

>>> Fraction(0.9)/Fraction(0.1)
Fraction(32425917317067572, 3602879701896397)
>>> Fraction(0.9)/Fraction(0.1) - 9
Fraction(-1, 3602879701896397)
>>> float(Fraction(0.9)/Fraction(0.1) - 9)
-2.7755575615628914e-16
>>> 9 + float(Fraction(0.9)/Fraction(0.1) - 9)
9.0

It is slightly smaller than 9, but the nearest float value is 9.0. Thus the result of the division is rounded up to 9.0.

A similar issue already was opened several months ago. I don't remember the number.
History
Date User Action Args
2018-01-13 00:07:48serhiy.storchakasetrecipients: + serhiy.storchaka, tim.peters, mark.dickinson, steven.daprano, Nathan.Goldbaum, ammar2
2018-01-13 00:07:48serhiy.storchakasetmessageid: <1515802068.13.0.467229070634.issue32543@psf.upfronthosting.co.za>
2018-01-13 00:07:48serhiy.storchakalinkissue32543 messages
2018-01-13 00:07:47serhiy.storchakacreate