Serhiy Storchaka added the comment: > I originally used the {n} approach but it was less clear and it lead to a > re-selection rather than undoing the rounding. That would change the output.
In normal case j is never equal to n. In very rare cases on platforms with double rounding the unpatched code generates an IndexError, and changing this is the purpose of the patch. Re-selection is so good as undoing the rounding. Please also note that double rounding causes an error not only when int(random() * n) == n. If random() returns 0.5 - 2**-54 and n = 2029*2, the result is different with double rounding and without it. This causes small bias even if IndexError is not raised. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24567> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com