diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2019-02-12 00:33:20 -0800 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-02-12 09:33:20 +0100 |
commit | bdc150adffccd339dd80e837d5d527206f651e88 (patch) | |
tree | 8f79adbd42ebf0b7178da230c252dd564360f4fa /lib/pure | |
parent | cc507668cbd76af0f5e1c9a36c43c1a23eeb00fb (diff) | |
download | Nim-bdc150adffccd339dd80e837d5d527206f651e88.tar.gz |
randomize: added doAssert(seed!=0) to avoid invalid (non-random) behavior (#10635)
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/random.nim | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/pure/random.nim b/lib/pure/random.nim index 85466ed9e..86db7da49 100644 --- a/lib/pure/random.nim +++ b/lib/pure/random.nim @@ -513,6 +513,7 @@ proc initRand*(seed: int64): Rand = let now = getTime() var r2 = initRand(now.toUnix * 1_000_000_000 + now.nanosecond) + doAssert seed != 0 # 0 causes `rand(int)` to always return 0 for example. result.a0 = ui(seed shr 16) result.a1 = ui(seed and 0xffff) discard next(result) |