[issue38703] should we expect round(0.95, 1) to be 1.0, instead of 0.9?

Mark Dickinson report at bugs.python.org
Wed Nov 6 08:08:52 EST 2019


Mark Dickinson <dickinsm at gmail.com> added the comment:

[Steven]

py> '%.17f' % 0.95
'0.94999999999999996'

That's tricky to use correctly: it's not a priori clear how many digits after the point are needed to give you a faithful representation (the "17" in "%.17f" isn't going to be the right thing for most values). You really want to specify the number of significant digits rather than the number of places after the point, and even then there are going to be cases where 17 significant digits aren't enough to show you which side of a tie the exact value lies.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38703>
_______________________________________


More information about the Python-bugs-list mailing list