I think this is the translation you want. The global initialization of z and w are the seeds. The upper and lower bounds are controlled via the addition of the lower bound to the calculation modulo the larger bound.
'http://www.mathematik.uni-bielefeld.de/~sillke/ALGORITHMS/random/marsaglia-inline-c
'#define znew (z=36969*(z&65535)+(z>>16))
'#define wnew (w=18000*(w&65535)+(w>>16))
'#define MWC ((znew<<16)+wnew )
Global z:Long=MilliSecs()'362436069
Global w:Long=MilliSecs()'521288629
For i=0 To 10
Print ""+dorand(1,100)
Next
Function dorand:Long(small:Long,large:Long)
z = 36969*(z & 65535)+(z Shr 16)
w = 18000*(w&65535)+(w Shr 16)
Return small+(((z Shl 16)+w) Mod large)
End Function
|