Skip to content

Instantly share code, notes, and snippets.

@taoyuan
Created February 10, 2020 06:11
Show Gist options
  • Save taoyuan/cfab28e47698c13df75eaa522ae2263c to your computer and use it in GitHub Desktop.
Save taoyuan/cfab28e47698c13df75eaa522ae2263c to your computer and use it in GitHub Desktop.
A linear congruential random generator
static uint32_t seed = 0;
static void srand32(uint32_t s) {
seed = s;
}
static uint32_t rand32(void) {
seed = (uint32_t)(((uint64_t)1664525 * seed) + 1013904223);
return seed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment