Test name | Executions per second |
---|---|
myFloat.toFixed(2) | 1412317.6 Ops/sec |
myFloat.toPrecision(2) | 1349155.6 Ops/sec |
Math.round(myFloat*100.0)/100.0 | 1317310.9 Ops/sec |
Bitwise: signed round ± to 2 places | 1366021.2 Ops/sec |
Bitwise: UNsigned round ± to 2 places | 1967181.6 Ops/sec |
myFloat.toFixed(0) | 1396065.2 Ops/sec |
Math.round() | 1422105.1 Ops/sec |
Bitwise: signed round ± to int | 2094295.2 Ops/sec |
Bitwise: UNsigned round ± to int | 3073216.5 Ops/sec |
Math.floor() round down | 1716588.8 Ops/sec |
Math.trunc() round toward zero | 1742731.1 Ops/sec |
Bitwise: round toward zero | 3115446.2 Ops/sec |