Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0
Firefox 117
Windows
Desktop
one year ago
Test name Executions per second
floor 250709808.0 Ops/sec
~~ 251400432.0 Ops/sec
>> 0 251846368.0 Ops/sec
| 0 251362608.0 Ops/sec
<< 0 251087216.0 Ops/sec
& 0xFFFFFFFFFFFF 250947728.0 Ops/sec
^ 0x000000000000 251169632.0 Ops/sec
Math.trunc() 250608672.0 Ops/sec
x - (x % 1) 929202240.0 Ops/sec
parseInt() 251178560.0 Ops/sec
Script Preparation code:
AخA
 
var x = Math.random() * 100000000;
var y;
Tests:
  • floor

     
    y = Math.floor(x);
  • ~~

     
    y = ~~x;
  • >> 0

     
    y = x >> 0;
  • | 0

     
    y = x | 0;
  • << 0

     
    y = x << 0;
  • & 0xFFFFFFFFFFFF

     
    y = x & 0xFFFFFFFFFFFF;
  • ^ 0x000000000000

     
    y = x ^ 0x000000000000;
  • Math.trunc()

     
    y = Math.trunc(x);
  • x - (x % 1)

     
    y = x - (x % 1);
  • parseInt()

     
    y = parseInt(x)