How to convert this RNG?
https://en.wikipedia.org/wiki/Xorshift
uint32_t xorshift32(void) {
state ^= state << 13;
state ^= state >> 17;
state ^= state << 5;
return state;
}
int randrange(int low,int high) {
return xorshift32()%(high-low+1)+low;
}
XOJO not giving exact results?
Dim m As New MemoryBlock(4)
m.LittleEndian = False
m.Int32Value(0) = 123456789
state = m.UInt32Value(0)
state = state Xor Bitwise.ShiftLeft(state, 13, 32)
state = state Xor Bitwise.ShiftRight(state, 17, 32)
state = state Xor Bitwise.ShiftLeft(state, 5, 32)
MsgBox Str(state)
Private Function randomRange(low As Integer, high As Integer) as Integer
state = randomSeed()
'MsgBox Str(state)
state = state Mod (high-low+1) + low
'MsgBox Str(state)
Return state
End Function