Tim Peters added the comment:

I suppose the simplest "fix" would be to replace relevant instances of

int(random() * N)

with

min(int(random() * N), N-1)

That would be robust against many kinds of arithmetic quirks, and ensure that 
platforms with and without such quirks would, if forced to the same internal 
random state, yield the same result when random() happens to return 1. - 
2.**-53.

Victor, what - precisely - do you have in mind with "only use integers"?  The 
current method was used because it's simple, efficient, and obvious.  Python 
3.4.3 appears to (usually) use a different method, though, relying on C code to 
generate random bytes without going through floats.

----------

_______________________________________
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

Reply via email to