blob: 85c2a2d345b2307e71dba1a5f4e14aa13894a524 [file] [log] [blame]
function marsaglia(m_z, m_w, n) {
var result;
for (var i = 0; i < n; ++i) {
m_z = (36969 * (m_z & 65535) + (m_z >> 16)) | 0;
m_w = (18000 * (m_w & 65535) + (m_w >> 16)) | 0;
result = ((m_z << 16) + m_w) | 0;
}
return result;
}
var result = 0;
for (var i = 0; i < 100; ++i)
result += marsaglia(i, i + 1, 1000000);
if (result != 8216386243)
throw "Error: bad result: " + result;