Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15
Safari 12
Mac OS X 10.12.6
Desktop
4 years ago
Test name Executions per second
floor 586793.9 Ops/sec
~~ 1045814.4 Ops/sec
>> 0 1015570.7 Ops/sec
| 0 1076381.4 Ops/sec
<< 0 1096779.4 Ops/sec
& 0xFFFFFFFFFFFF 1143643.4 Ops/sec
^ 0x000000000000 1224442.2 Ops/sec
Math.trunc() 638458.4 Ops/sec
x - (x % 1) 806953.6 Ops/sec
parseInt() 662004.9 Ops/sec
Script Preparation code:
Tests:
  • floor

  • ~~

  • >> 0

  • | 0

  • << 0

  • & 0xFFFFFFFFFFFF

  • ^ 0x000000000000

  • Math.trunc()

  • x - (x % 1)

  • parseInt()