proc rand*(maxval: uint32): uint32 =
let limit = uint32(high(uint32)) - uint32(high(uint32)) mod maxval
var bits = rand_u32()
while bits > limit:
bits = rand_u32()
result = bits mod maxval
Looks suspicious. high - high is 0, isn't it? And there are MUCH more effective ways than `while bits > limit` (super slow for small numbers?).
