Created
September 14, 2020 08:20
-
-
Save chiro-hiro/bdf2198e50d6dbca310f1d6e34b3db5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
struct xorshift128p_state { | |
uint64_t a, b; | |
}; | |
/* The state must be seeded so that it is not all zero */ | |
uint64_t xorshift128p(struct xorshift128p_state *state) | |
{ | |
uint64_t t = state->a; | |
uint64_t const s = state->b; | |
state->a = s; | |
t ^= t << 23; // a | |
t ^= t >> 17; // b | |
t ^= s ^ (s >> 26); // c | |
state->b = t; | |
return t + s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment