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-13 23:30:14 +0100 |
commit | 304b1dd34bc52df29528c2a12f769cb59904db5a (patch) | |
tree | 74b117c2a8b8c1106239ee523a7e470166db2280 /lib/pure/random.nim | |
parent | e3ba2e24cf3051fcf59fa5b18f21ff84e7f94f5e (diff) | |
download | Nim-304b1dd34bc52df29528c2a12f769cb59904db5a.tar.gz |
randomize: added doAssert(seed!=0) to avoid invalid (non-random) behavior (#10635)
Diffstat (limited to 'lib/pure/random.nim')
-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) |