Created
June 24, 2011 18:50
-
-
Save inspirit/1045410 to your computer and use it in GitHub Desktop.
A 32-bit random number generator by George Marsaglia
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
var __x:uint = 123456789; | |
var __y:uint = 362436069; | |
var __z:uint = 21288629; | |
var __w:uint = 14921776; | |
var __c:uint = 0; | |
function rnd():uint | |
{ | |
__x = __x + 545925293; | |
__y = __y ^ (__y<<13); | |
__y = __y ^ (__y>>17); | |
__y = __y ^ (__y<<5); | |
var t:uint = __z + __w + __c; | |
__z = __w; | |
__c = (t >> 31); | |
__w = t & 2147483647; | |
return (__x + __y + __w); | |
} | |
function random():Number | |
{ | |
return (rnd()*2.32830643708e-10); // 1 / 2^32 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment