[issue41598] rnd() + rndup() in math

Vedran Čačić report at bugs.python.org
Sat Aug 22 14:28:24 EDT 2020


Vedran Čačić <vedgar at gmail.com> added the comment:

> use more digits to manage rounding in decimal base, not only one but more (i should think better and experiment on how many)

You don't have to. It's infinitely many. :-P Think, how many decimal digits would you need to accurately round numbers to a closest third (one trinary digit)? Here are some decimal digits: 2.166666666. If the next digit is 5, then it rounds to 2.0. If it is 7, it rounds to 2.1 (base 3). If it is 6, you still don't know anything. It can go arbitrarily far. Of course, the probability is lower with every digit, and at some point it becomes acceptable (you said for yourself it's acceptable even with one extra digit), but it's not mathematically correct.

And that one bit was just an illustration. In real life, 64-bit machines usually use at least 80-bit precision, so 16 extra bits. But it doesn't help your case, for the above reasons: this is simply not decimal rounding.

----------

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


More information about the Python-bugs-list mailing list