Skip to content

Instantly share code, notes, and snippets.

@tsvetomir
Created April 27, 2015 13:01
Show Gist options
  • Save tsvetomir/4fc4497621c0cc023958 to your computer and use it in GitHub Desktop.
Save tsvetomir/4fc4497621c0cc023958 to your computer and use it in GitHub Desktop.
PRNG - Linear feedback shift register
var random = (function() {
// Implements 32-bit Linear feedback shift register
var lfsr = 0xDEADBEEF;
return function() {
lfsr = ((lfsr >>> 1) ^ (-(lfsr & 1) & 0xD0000001)) >>> 0;
return lfsr;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment