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 terry.reedy
Recipients AVicennA, docs@python, koobs, mark.dickinson, ned.deily, paul.moore, ronaldoussoren, steve.dower, steven.daprano, terry.reedy, tim.golden, zach.ware
Date 2019-12-16.18:46:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576522019.45.0.637049447613.issue39059@roundup.psfhosted.org>
In-reply-to
Content
The flaw in my_round is that it rounds twice, not once.  The first rounding is caused by multiplying by a factor that is not a power of 2.  

In the case of 2.675, that rounding is up enough to affect the second rounding.
>>> format(2.675, ".17f")
'2.67499999999999982'
>>> format(2.675 *100, ".17f")
'267.50000000000000000'

In the case of 4.395, the first rounding is down.
>>> format(4.395, ".17f")
'4.39499999999999957'
>>> format(4.395 *100, ".17f")
'439.49999999999994316'
Even if it had been up, it might not have been enough to affect the outcome, as 57 is a lot farther from 100 than 82.

If you want to discuss floating point approximations and rounding further, please post to python-list, not here.
History
Date User Action Args
2019-12-16 18:46:59terry.reedysetrecipients: + terry.reedy, paul.moore, ronaldoussoren, mark.dickinson, tim.golden, ned.deily, steven.daprano, docs@python, zach.ware, koobs, steve.dower, AVicennA
2019-12-16 18:46:59terry.reedysetmessageid: <1576522019.45.0.637049447613.issue39059@roundup.psfhosted.org>
2019-12-16 18:46:59terry.reedylinkissue39059 messages
2019-12-16 18:46:59terry.reedycreate