Created
November 18, 2013 07:32
-
-
Save kr9ly/7524003 to your computer and use it in GitHub Desktop.
XorShift.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function XRandom(seed) { | |
this.x = 123456789; | |
this.y = 362436069; | |
this.z = 521288629; | |
this.w = seed; | |
} | |
XRandom.prototype.rand = function () { | |
var t; | |
t = this.x ^ (this.x << 11); | |
this.x = this.y; | |
this.y = this.z; | |
this.z = this.w; | |
this.w = this.w=(this.w^(this.w>>19))^(t^(t>>8)) | |
return this.w; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment