[Newbies] What's wrong with this statement?

johnps11 at bigpond.com johnps11 at bigpond.com
Thu Jul 31 23:37:27 UTC 2008


The issue is almost certainly in atRandom:

Running

30  timesRepeat: [ | a |
    a:= (2 raisedTo: 57) atRandom.
    Transcript show: a ; show:  ' ' ; show: a even ; cr ].

Gives me 30 falses.

The odds of that are less than one in a billion (assuming uniformly
distributed integers).

This doesn't happen for 2^56 or lower, and does for all 2^n, n>= 57.

My guess is that it's either a hardware issue or something about Random. 
I'm not clever enough to understand PRNGs, so I'll leave it others to work
out what the answer is, although I suspect that for more than 56 bits you
need a PRNG that uses LargeIntegers  and not Floats.



More information about the Beginners mailing list