[issue32956] python 3 round bug

Mark Dickinson report at bugs.python.org
Wed Sep 26 07:46:40 EDT 2018


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

@jab: Did you see this message from the thread that Serhiy pointed to? https://mail.python.org/pipermail/python-dev/2008-January/075910.html

Here's the sound bite version, but see the message for context:

[Guido]
> Wow. Do you have an opinion as to whether we should adopt
> round-to-even at all (as a default)?

[Tim]
Yes:  yes :-)  [...]

Note that Python is not alone here: .NET also uses round-ties-to-even as the default rounding mode. Note also that the languages you mention don't all agree with one another either: try rounding -2.5 to the nearest integer in JavaScript and see what result you get.

[Joshua]
> and whether it would therefore be better exposed as an additional function (e.g. "round_to_even" or "round_unbiased"

Changing the default behaviour of `round` again seems highly undesirable to me; I'd be strongly opposed to such a change. Proposals for backwards-compatible changes that make the round-ties-away-from-zero function available again under a different name (or via a keyword argument to `round`) could be worth discussing. And suggestions/PRs for documentation clarification are welcome, of course.

----------

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


More information about the Python-bugs-list mailing list