Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.63
Chrome 104
Windows
Desktop
2 years ago
Test name Executions per second
floor 267459.4 Ops/sec
~~ 565342.7 Ops/sec
>> 0 519102.4 Ops/sec
| 0 580588.6 Ops/sec
<< 0 518194.4 Ops/sec
& 0xFFFFFFFFFFFF 497636.6 Ops/sec
^ 0x000000000000 545902.1 Ops/sec
Math.trunc() 315080.3 Ops/sec
x - (x % 1) 371408.1 Ops/sec
parseInt() 290187.2 Ops/sec
Script Preparation code:
Tests:
  • floor

  • ~~

  • >> 0

  • | 0

  • << 0

  • & 0xFFFFFFFFFFFF

  • ^ 0x000000000000

  • Math.trunc()

  • x - (x % 1)

  • parseInt()