In the programming language I'm using (GML) all numbers are confined to signed int64s (or float64s). How would I implement this XORshift128+ pRNG (currently coded in C) with that sort of limitation? I would also accept a higher bit count if the programming would be easier.
static uint32_t s[4] = { 0x8764000b, 0xf542d2d3, 0x6fa035c3, 0x77f2db5b };
static inline uint32_t rotl(const uint32_t x, int k) {
return (x << k) | (x >> (32 - k));
}
uint32_t next(void) {
const uint32_t result = s[0] + s[3];
const uint32_t t = s[1] << 9;
s[2] ^= s[0];
s[3] ^= s[1];
s[1] ^= s[2];
s[0] ^= s[3];
s[2] ^= t;
s[3] = rotl(s[3], 11);
return result;
}
Aucun commentaire:
Enregistrer un commentaire