Skip to content

Instantly share code, notes, and snippets.

@andresroberto
Last active June 21, 2021 09:59
Show Gist options
  • Save andresroberto/808fdab9186c7b2b75cfff492e45ad5e to your computer and use it in GitHub Desktop.
Save andresroberto/808fdab9186c7b2b75cfff492e45ad5e to your computer and use it in GitHub Desktop.
const RAND_MAX = 0xffff; // 65535
const next = new Uint32Array([0]);
export function srand(seed) {
next[0] = seed;
}
export function rand() {
next[0] = next[0] * 1103515245 + 12345;
return ((next[0] % ((RAND_MAX + 1) <<8)) >>8);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment