Hey there!
I have been playing with nim for a few days. Now I stumbled upon a behavior
that I do not understand.
The random generator does not behave like I expect.
import random
randomize()
echo random(1280)
This should echo a "random" number between 0 and 1280 (-1) right? Well, it
does, kind of.
* * *
nim c -r rnd.nim
1118
nim c -r rnd.nim
1117
nim c -r rnd.nim
1116
nim c -r rnd.nim
1116
nim c -r rnd.nim
1117
* * *
This one behaves more random:
import random
randomize()
for i in 1..10
echo random(1200)
nim c -r rnd.nim
841
1014
609
635
547
574
1171
233
280
595
nim c -r rnd.nim
780
275
1029
985
1143
865
686
97
945
858
nim c -r rnd.nim
793
166
604
244
338
868
482
281
173
7
* * *
Is there a smarter way to create a random number with min/max value?