On Jul 31, 2008, at 3:01 PM, nicolas cellier wrote:
Random>>#next uses Floating point arithmetic. Thus you get the 53 bits precision of a Float mantissa (IEEE 754 double). It then gets shifted (128-53) times. There's probably a trick that rounds Float last bit to zero (like round to nearest integer always occur). And you might be able to understand the trailing 1.
Worse, the default Random generator does a modulo (2 raisdeTo: 31) -
That is, it can generate at most (2 raisdeTo: 31) different numbers... That happens to be the number of SmallInteger in the system, so it probably works better for SmallIntegers. A different strategy should be adopted for LargePositiveInteger>>atRandom... Let us say current implementation is very limited...
I suggest you open a mantis account and report the issue at http://bugs.squeak.org
First I'll dig into the Cryptography package and see what they did for large random numbers.
It certainly is inconsistent to have an Integer method that doesn't invisibly handle large ints.
-- Tim