Skip to content
Permalink
Browse files

randomize: added doAssert(seed!=0) to avoid invalid (non-random) beha…

…vior (#10635)
  • Loading branch information...
Timothee Cour authored and Araq committed Feb 12, 2019
1 parent e3ba2e2 commit 304b1dd34bc52df29528c2a12f769cb59904db5a
Showing with 1 addition and 0 deletions.
  1. +1 −0 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)

0 comments on commit 304b1dd

Please sign in to comment.
You can’t perform that action at this time.