Random number generators

From vegard.wiki
Revision as of 15:36, 20 February 2021 by Vegard (talk | contribs) (categorise)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

pcg32()

// https://twitter.com/zeuxcg/status/1363143368033755136
uint32_t pcg32(uint64_t* s) {
  uint32_t x = ((*s >> 18u) ^ *s) >> 27u;
  uint32_t r = *s >> 59u;
  *s  = *s * 6364136223846793005ULL + 1;
  return (x >> r) | (x << ((-r) & 31));
}

See also