This commit is contained in:
Alwin Berger 2023-03-14 16:53:19 +01:00
parent 6650ad2ad3
commit 04a2ee3f45

View File

@ -19,10 +19,12 @@ volatile long _NONSENSE_VAR = 0;
#define CLAMP(X,LB,UB) CLAMP_CEILING(CLAMP_FLOOR(X,LB),UB) // branch-less clamping
// Random numbers ===
#define A (unsigned int)2000000011 // prime
#define M (unsigned int)4000000007 // prime
#define C (unsigned int)1283612343
static unsigned int rng_seed = 2345745;
// glibc
// https://en.wikipedia.org/wiki/Linear_congruential_generator
#define A 1103515245ull
#define M 0x80000000ull
#define C 12345ull
static unsigned long long rng_seed = 2345745ull;
#define RNG rng_seed+=((A*((rng_seed+=C)-C)+C) % M)
#define RNG_FROM(X) ((A*X+C) % M)