Skip to content

Instantly share code, notes, and snippets.

@martian17
Created December 23, 2022 01:15
Show Gist options
  • Save martian17/8eede596cf3b226f05ad1f970e50dbbc to your computer and use it in GitHub Desktop.
Save martian17/8eede596cf3b226f05ad1f970e50dbbc to your computer and use it in GitHub Desktop.
inspect Math.random
{
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