I have used your code, but adjusted the myrand with int(~~) , to give a more uniform distribution, which is shown.
Also, I have noticed a little error in my previous range functions, (the positions of the brackets within)
My gripe is not with the mode of getting rnd(), but with the way gcc seems to fail within high ranges.
This seems OK with -gen gas, but fails with -gen gcc, try with 64 bit fbc for example.
Code: Select all
dim as ulongint k=-1
'4294967295 ulong max
'18446744073709551615 ulongint max
dim as ulongint offset=12345678909876543210
Dim As ulongint MyMin=0, MyMax=5, MyRand
print mymin;" to ";mymax
dim as ulong a(0 to mymax - mymin)
dim as ulongint errors
Dim As ulongint MyRange=(MyMax-MyMin)
for i As integer=1 to 10000000
if myrand>mymax then errors+=1
if myrand<mymin then errors+=1
for n as long=lbound(a) to ubound(a)
print n, a(n)
print "errors ";errors
Of course I could be not seeing something obvious.