Test name | Executions per second |
---|---|
floor | 3843902.0 Ops/sec |
~~ | 6460320.5 Ops/sec |
>> 0 | 6473022.0 Ops/sec |
| 0 | 6513680.0 Ops/sec |
<< 0 | 6470605.0 Ops/sec |
& 0xFFFFFFFFFFFF | 5573793.5 Ops/sec |
^ 0x000000000000 | 4955018.5 Ops/sec |
Math.trunc() | 2604804.2 Ops/sec |
x - (x % 1) | 3112664.2 Ops/sec |
parseInt() | 1928593.6 Ops/sec |
var x = Math.random() * 100000000;
var y;
y = Math.floor(x);
y = ~~x;
y = x >> 0;
y = x | 0;
y = x << 0;
y = x & 0xFFFFFFFFFFFF;
y = x ^ 0x000000000000;
y = Math.trunc(x);
y = x - (x % 1);
y = parseInt(x)