*state) { uint64_t* s = state->s; uint64_t const result = s[0] + s[3]; uint64_t const t = s[1] << 17; s[2] ^= s[0]; s[3] ^= s[1]; s[1] ^= s[2]; s[0] ^= s[3]; s[2] ^= t; s[3] = rol64(s[3], 45); return result; } xoroshiro If space is at a premium, xoroshiro128** and xoroshiro128+ are equivalent to xoshiro256** and xoshiro256+. These have smaller state spaces, and thus are less useful for massively parallel programs. xoroshiro128+ also exhibits a mild dependency in the population count, generating a failure after of output. The authors do not believe that this can be detected in real world programs. xoroshiro64** and xoroshiro64* are equivalent to xoroshiro128** and xoroshiro128+. Unlike the xoshiro generators, they are not straightforward ports of their higher-precision counterparts. Initialization In the xoshiro paper, it is recommended to initialize the state of the generators using a generator which is radically different from the initialized generators, as well as one which will never give the "all-zero" state; for shift-register generators, this state is impossible to escape from. The authors specifically recommend using the SplitMix64 generator, from a 64-bit seed, as follows: #include <stdint.h> struct splitmix64_state { uint64_t s; }; uint64_t splitmix64(struct splitmix64_state *state) { uint64_t result = (state->s += 0x9E3779B97f4A7C15); result = (result ^ (result >> 30)) * 0xBF58476D1CE4E5B9; result = (result ^ (result >> 27)) * 0x94D049BB133111EB; return result ^ (result >> 31); } struct xorshift128_state { uint32_t x[4]; }; // one could do the same for any of the other generators void xorshift128_init(struct xorshift128_state *state, uint64_t seed) { struct splitmix64_state smstate = {seed}; uint64_t tmp = splitmix64(&smstate); state->x[0] = (uint32_t)tmp; state->x[1] = (uint32_t)(tmp >> 32); tmp = splitmix64(&smstate); state->x[2] = (uint32_t)tmp; state->x[3] = (uint32_t)(tmp >> 32); } Notes References Further reading Lists generators of various sizes with four shifts (two per feedback word). Pseudorandom number generators