[squeak-dev] Bad value for Random seed ?
Levente Uzonyi
leves at elte.hu
Sun Sep 21 15:14:26 UTC 2014
On Sun, 21 Sep 2014, Stéphane Rollandin wrote:
> Hello,
>
> (Random seed: 16457315536128) nextInt: 11
>
> gives -1853
>
>
> Am I missing something ?
It's not documented, but this generator[1] is designed to work with 32 bit
integers. #nextValue generates 31 bit integers between 1 and 2147483647.
This actually breaks #next, which returns a value from (0..1] instead
of [0..1).
Based on the math in #nextValue seeds up to 96752654378 are safe, but
96752654379 will underflow. I suggest you to use 31 bit nonnegative
integers as seed.
Levente
[1] http://www.cems.uwe.ac.uk/~irjohnso/coursenotes/ufeen8-15-m/p1192-parkmiller.pdf
>
> Stef
>
>
More information about the Squeak-dev
mailing list
|