Test name | Executions per second |
---|---|
myFloat.toFixed(2) | 686650.6 Ops/sec |
myFloat.toPrecision(2) | 916620.9 Ops/sec |
Math.round(myFloat*100.0)/100.0 | 888427.9 Ops/sec |
Bitwise: signed round ± to 2 places | 1010021.7 Ops/sec |
Bitwise: UNsigned round ± to 2 places | 1385122.8 Ops/sec |
myFloat.toFixed(0) | 668558.1 Ops/sec |
Math.round() | 954068.8 Ops/sec |
Bitwise: signed round ± to int | 952099.2 Ops/sec |
Bitwise: UNsigned round ± to int | 1354401.0 Ops/sec |
Math.floor() round down | 856373.4 Ops/sec |
Math.trunc() round toward zero | 876845.7 Ops/sec |
Bitwise: round toward zero | 1442250.2 Ops/sec |