MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / nextrand

Function nextrand

extlibs/lua/src/lmathlib.c:307–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307static Rand64 nextrand (Rand64 *state) {
308 Rand64 state0 = state[0];
309 Rand64 state1 = state[1];
310 Rand64 state2 = state[2] ^ state0;
311 Rand64 state3 = state[3] ^ state1;
312 Rand64 res = rotl(state1 * 5, 7) * 9;
313 state[0] = state0 ^ state3;
314 state[1] = state1 ^ state2;
315 state[2] = state2 ^ (state1 << 17);
316 state[3] = rotl(state3, 45);
317 return res;
318}
319
320
321/* must take care to not shift stuff by more than 63 slots */

Callers 3

projectFunction · 0.85
math_randomFunction · 0.85
setseedFunction · 0.85

Calls 6

rotlFunction · 0.85
times9Function · 0.85
times5Function · 0.85
IshlFunction · 0.85
IxorFunction · 0.85
rotl1Function · 0.85

Tested by

no test coverage detected