diff options
author | Araq <rumpf_a@web.de> | 2017-01-08 14:00:52 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-01-08 14:00:52 +0100 |
commit | 6acfbb9e1d9ea64d4ad22e4f13d7e187b45c674d (patch) | |
tree | 2f1464c6bba02a6c6862cf1e366f4626eebe11d8 /lib | |
parent | 13649778c1fc4ffba0d51368f231fc2ff1a0c86d (diff) | |
download | Nim-6acfbb9e1d9ea64d4ad22e4f13d7e187b45c674d.tar.gz |
make random.nim work for the JS target again
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/random.nim | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/pure/random.nim b/lib/pure/random.nim index 9484557a9..0d4996400 100644 --- a/lib/pure/random.nim +++ b/lib/pure/random.nim @@ -19,10 +19,12 @@ include "system/inclrtl" # XXX Expose RandomGenState when defined(JS): type ui = uint32 + + const randMax = 4_294_967_295u32 else: type ui = uint64 -const randMax = 18_446_744_073_709_551_615u64 + const randMax = 18_446_744_073_709_551_615u64 type RandomGenState = object @@ -76,7 +78,7 @@ proc random*(max: int): int {.benign.} = ## number, i.e. a tickcount. while true: let x = next(state) - if x < randMax - (randMax mod uint64(max)): + if x < randMax - (randMax mod ui(max)): return int(x mod uint64(max)) proc random*(max: float): float {.benign.} = |