Random number generators: Difference between revisions

From vegard.wiki
Jump to navigation Jump to search
Content added Content deleted
(new page)
 
(categorise)
 
Line 14: Line 14:


* PCG paper: https://www.pcg-random.org/pdf/hmc-cs-2014-0905.pdf
* PCG paper: https://www.pcg-random.org/pdf/hmc-cs-2014-0905.pdf

[[Category:C]] [[Category:Programming]]

Latest revision as of 15:36, 20 February 2021

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