diff options
author | apense <apense@users.noreply.github.com> | 2015-06-11 18:56:59 -0400 |
---|---|---|
committer | apense <apense@users.noreply.github.com> | 2015-06-11 18:56:59 -0400 |
commit | 7fba7d934b04d7a602944c1a8d0785e6d6a34b9a (patch) | |
tree | b7e4c7c93325eabe89a15406a374de400304960d /lib/pure | |
parent | 294989daf515d8cad63bb30a8a80e39a45766a80 (diff) | |
download | Nim-7fba7d934b04d7a602944c1a8d0785e6d6a34b9a.tar.gz |
Discarded randomize for windows
It actually doesn't use it because `rand_s` doesn't.
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/math.nim | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/pure/math.nim b/lib/pure/math.nim index 6c03dee4f..34070dd91 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -217,6 +217,12 @@ when not defined(JS): proc drand48(): float {.importc: "drand48", header: "<stdlib.h>".} proc random(max: float): float = result = drand48() * max + proc randomize() = + randomize(cast[int](epochTime())) + + proc randomize(seed: int) = + srand(cint(seed)) # rand_s doesn't use srand + srand48(seed) when defined(windows): proc random(max: float): float = # we are hardcodeing this because @@ -226,12 +232,9 @@ when not defined(JS): # See https://msdn.microsoft.com/en-us/library/296az74e.aspx const rand_max = 4294967295 result = (float(rand()) / float(rand_max)) * max - proc randomize() = - randomize(cast[int](epochTime())) - - proc randomize(seed: int) = - when declared(srand): srand(cint(seed)) # rand_s doesn't use srand - when declared(srand48): srand48(seed) + proc randomize() = discard + proc randomize(seed: int) = discard + proc random(max: int): int = result = int(rand()) mod max |