From bdc150adffccd339dd80e837d5d527206f651e88 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Tue, 12 Feb 2019 00:33:20 -0800 Subject: [PATCH] randomize: added doAssert(seed!=0) to avoid invalid (non-random) behavior (#10635) --- lib/pure/random.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pure/random.nim b/lib/pure/random.nim index 85466ed9ef..86db7da497 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)