[issue24567] random.choice IndexError due to double-rounding

Mark Dickinson report at bugs.python.org
Sun Jul 5 16:28:29 CEST 2015


Mark Dickinson added the comment:

Note that this affects other Random methods, too.  There are several places in the source where something of the form `int(i * random.random())` is used to select an integer in the half-open range [0, i).

And a nitpick: it's a stretch to describe double-rounding on multiplication (or any other arithmetic operation) as a bug: Python-the-language makes no promises about adhering to IEEE 754 arithmetic rule.  (In fact, it makes no promises about using IEEE 745 formats in the first place.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24567>
_______________________________________


More information about the Python-bugs-list mailing list