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

marco_ocram report at bugs.python.org
Sat Aug 22 04:09:03 EDT 2020


marco_ocram <m.balzaretti at eureka-market.com> added the comment:

@Vedran:
I'm sorry about my "quick-and-dirty implementations". As i've already stated the problem's more deep i expect, despite the second half up rounding for my needs now (after your observation) work well. I've verified other languages have the same problem with floats operations and roundings.

@Steven:
"Are you satisfied that adding a rounding mode to the built-in `round` function is a better solution than a series of functions in the math module? If so, I will change the title to reflect that."
I fully agree with the sentence and with all the content of your writings. I think the decimal module is excellent and can do an extraordinary work (as extraordinary i suppose was the work of its coders) but floats also are fine for common people use, i see only the rounding as main them problem. It's very unpleasant to round 2.8-1.3 half up and without tricks obtain a misleading results.
I think working on the last decimal digit if all are used the problem could be solved, but with a lot of study (at least for me if i have) cause one purpose have to be maintain good performances in addition to results always corrects.

This is only a possibility to improve the core language, i think one function with more common rounding ways, as in wikipedia (in gnu c i don't see just "to nearest, ties away from zero" or half up we discuss) or in decimals module, can be useful to reduce the need of individual coders implementation on a not so simple question cause them needs not satisfied by the round() as banking rounding.

----------

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


More information about the Python-bugs-list mailing list