Message246641
> 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. |
|
Date |
User |
Action |
Args |
2015-07-12 08:30:27 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, tim.peters, rhettinger, mark.dickinson, pitrou, vstinner, steven.daprano, r.david.murray, skrah, Serge Anuchin |
2015-07-12 08:30:27 | serhiy.storchaka | set | messageid: <1436689827.61.0.794783046546.issue24567@psf.upfronthosting.co.za> |
2015-07-12 08:30:27 | serhiy.storchaka | link | issue24567 messages |
2015-07-12 08:30:27 | serhiy.storchaka | create | |
|