diff options
author | Guido van Rossum <guido@python.org> | 1998-02-16 14:52:42 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-02-16 14:52:42 (GMT) |
commit | 358473c1a2a692a496bbbeca330c1e4d52fc78b0 (patch) | |
tree | 8fa13b3a6433938b016309b43e1b296835a21bcc /Lib/whrandom.py | |
parent | 1aedbd8b0aabdb2a68748df4d1f10e2577e8d027 (diff) | |
download | cpython-358473c1a2a692a496bbbeca330c1e4d52fc78b0.zip cpython-358473c1a2a692a496bbbeca330c1e4d52fc78b0.tar.gz cpython-358473c1a2a692a496bbbeca330c1e4d52fc78b0.tar.bz2 |
Andrew Kuchling writes:
First, the RNG in whrandom.py sucks if you let it seed itself from the time.
The problem is the line:
t = int((t&0xffffff) | (t>>24))
Since it ORs the two parts together, the resulting value has mostly
ON bits. Change | to ^, and you don't lose any randomness.
Diffstat (limited to 'Lib/whrandom.py')
-rw-r--r-- | Lib/whrandom.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/whrandom.py b/Lib/whrandom.py index bd2dcf7..95e88f3 100644 --- a/Lib/whrandom.py +++ b/Lib/whrandom.py @@ -50,7 +50,7 @@ class whrandom: # Initialize from current time import time t = long(time.time() * 256) - t = int((t&0xffffff) | (t>>24)) + t = int((t&0xffffff) ^ (t>>24)) t, x = divmod(t, 256) t, y = divmod(t, 256) t, z = divmod(t, 256) |