Originally Posted by

**Milk**
In terms of other pseudo random number generators Rnd uses a fairly weak algorithm. The full sequence consists of exactly 16777216 (&h1000000) different numbers (every number being multiple of 1/16777216), divide that by 256 and we are only left with 65536 different entry points.

I've been trying to test this assertion but I can't seem to verify it. I wrote the following program to test it.

Code:

Const STEPS As Long = 100000000 ' 100 million iterations
Const SIZE As Long = &H1000000 ' Numbers in sequence
ReDim a(SIZE) As Boolean
Dim i As Long, r As Single, j As Long, c As Long
For i = 1 To STEPS
' Reseed on each iteration to get a new entry point...
Randomize
' Get the random number at this entry point...
r = Rnd()
' Convert from Single to Long...
j = r * SIZE
' Flag it in our array as being visited and increment our unique entry-point count...
If Not a(j) Then
a(j) = True
c = c + 1
End If
Next
MsgBox "Unique entry points: " & c

This returns over 300,000 entry points. Not nearly 16+ million but also not 65,536.

Is there something flawed with this test?