Skip to content

Instantly share code, notes, and snippets.

@hbsnow
Last active December 15, 2015 21:29
Show Gist options
  • Save hbsnow/5326596 to your computer and use it in GitHub Desktop.
Save hbsnow/5326596 to your computer and use it in GitHub Desktop.
Xorshift による疑似乱数生成
// xor128 class
var xor128 = {
// member
x: 123456789,
y: 362436069,
z: 521288629,
w: 88675123,
// method
setSeed: function(seed){
this.w = seed;
},
generate: function(){
var t = this.x ^ (this.x << 11);
this.x = this.y;
this.y = this.z;
this.z = this.w;
this.w = (this.w ^ (this.w >>> 19) ^ (t ^ (t >>> 8))) >>> 0;
return this.w;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment