convert to 32bit

Benchmark created on


Setup

const numbers = [];

for (let i = 0; i < 100000; i++) {
	numbers.push(Math.floor(Math.random() * 0xffffffff) + Math.random());
}

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor
let sum = 0;

numbers.forEach(n => sum += Math.floor(n));
ready
~~
let sum = 0;

numbers.forEach(n => sum += ~~n);
ready
| 0
let sum = 0;

numbers.forEach(n => sum += n | 0);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.