Created
December 23, 2022 01:15
-
-
Save martian17/8eede596cf3b226f05ad1f970e50dbbc to your computer and use it in GitHub Desktop.
inspect Math.random
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
{ | |
let ab = new ArrayBuffer(8); | |
let f = new Float64Array(ab); | |
let ints = new Int32Array(ab); | |
let tally = newarr(64); | |
for(let i = 0; i < 100000; i++){ | |
f[0] = Math.random(); | |
for(let i = 31; i >= 0; i--){ | |
tally[31-i] += ((ints[0]>>i)&1); | |
} | |
for(let i = 31; i >= 0; i--){ | |
tally[32+31-i] += ((ints[1]>>i)&1); | |
} | |
} | |
console.log(tally); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment