Skip to content

Instantly share code, notes, and snippets.

@warmwaffles
Created June 10, 2018 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warmwaffles/a3988b2a50a8608b01d9f256a35569b9 to your computer and use it in GitHub Desktop.
Save warmwaffles/a3988b2a50a8608b01d9f256a35569b9 to your computer and use it in GitHub Desktop.
#include <stdint.h>
uint64_t s[2];
uint64_t
xorshiftrng128(void)
{
uint64_t s1 = s[0];
uint64_t s0 = s[1];
uint64_t result = s0 + s1;
s[0] = s0;
s1 ^= s1 << 23; // a
s[1] = s1 ^ s0 ^ (s1 >> 18) ^ (s0 >> 5); // b, c
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment