MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / nextrand

Function nextrand

3rd/lua-5.4.3/src/lmathlib.c:308–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308static Rand64 nextrand (Rand64 *state) {
309 Rand64 state0 = state[0];
310 Rand64 state1 = state[1];
311 Rand64 state2 = state[2] ^ state0;
312 Rand64 state3 = state[3] ^ state1;
313 Rand64 res = rotl(state1 * 5, 7) * 9;
314 state[0] = state0 ^ state3;
315 state[1] = state1 ^ state2;
316 state[2] = state2 ^ (state1 << 17);
317 state[3] = rotl(state3, 45);
318 return res;
319}
320
321
322/* 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

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

Tested by

no test coverage detected