Mantis - Squeak
Viewing Issue Advanced Details
3473 Kernel minor always 04-16-06 01:05 04-17-06 20:22
new 3.8  
0003473: class Random quirks (bugs really)
The documentation in class Random method #nextValue states:

"This method generates random instances of Integer
 in the interval 0 to 16r7FFFFFFF."

In fact, it generates floats.
One possible fix is to change the comment but #nextValue
is a low level private method and as such it should generate small integers.
A second problem is that if the result of #nextValue is converted to an
integer it is a large integer about half the time.

Also, Class Random should ideally have a public method #nextInteger,
which if called enough times, generates all small integers in some random order.
I need such a method for my application.
(I use them as hash values for objects.)

Class random has a method #nextInt: which generates random integers in a
range. This method should only use small integers, never floats as it does

A final comment:
When Squeak begins to run on 64 bit machines it will need to support
a version of Random in which random numbers in the range supported by 64 bit
squeak are generated.

There are no notes attached to this issue.