has a maximal period of 2128−1. #include <stdint.h> struct xorshift128p_state { uint64_t x[2]; }; /* The state must be seeded so that it is not all zero */ uint64_t xorshift128p(struct xorshift128p_state *state) { uint64_t t = state->x[0]; uint64_t const s = state->x[1]; state->x[0] = s; t ^= t << 23; // a t ^= t >> 18; // b -- Again, the shifts and the multipliers are tunable t ^= s ^ (s >> 5); // c state->x[1] = t; return t + s; } xoshiro xoshiro and xoroshiro use rotations in addition to shifts. According to Vigna, they are faster and produce better quality output than xorshift. This class of generator has variants for 32-bit and 64-bit integer and floating point output; for floating point, one takes the upper 53 bits (for binary64) or the upper 23 bits (for binary32), since the upper bits are of better quality than the lower bits in the floating point generators. The algorithms also include a jump function, which sets the state forward by some number of steps – usually a power of two that allows many threads of execution to start at distinct initial states. For 32-bit output, xoshiro128** and xoshiro128+ are exactly equivalent to xoshiro256** and xoshiro256+, with in place of , and with different shift/rotate constants. More recently, the generators have been made as an alternative to the generators. They are used in Java and Julia. xoshiro256** xoshiro256** is the family's general-purpose random 64-bit number generator. It is used in Lua and the .NET Framework. /* Adapted from the code included on Sebastiano Vigna's website */ #include <stdint.h> uint64_t rol64(uint64_t x, int k) { return (x << k) | (x >> (64 - k)); } struct xoshiro256ss_state { uint64_t s[4]; }; uint64_t xoshiro256ss(struct xoshiro256ss_state *state) { uint64_t *s = state->s; uint64_t const result = rol64(s[1] * 5, 7) * 9; 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; } xoshiro256+ xoshiro256+ is approximately 15% faster than xoshiro256**, but the lowest three bits have low linear complexity; therefore, it should be used only for floating point results by extracting the upper 53 bits. #include <stdint.h> uint64_t rol64(uint64_t x, int k) { return (x << k) | (x >> (64 - k)); } struct xoshiro256p_state { uint64_t s[4]; }; uint64_t xoshiro256p(struct xoshiro256p_state