Test name | Executions per second |
---|---|
myFloat.toFixed(2) | 3975132.2 Ops/sec |
myFloat.toPrecision(2) | 3440480.5 Ops/sec |
Math.round(myFloat*100.0)/100.0 | 387574752.0 Ops/sec |
Bitwise: signed round ± to 2 places | 3069093.2 Ops/sec |
Bitwise: UNsigned round ± to 2 places | 392308704.0 Ops/sec |
myFloat.toFixed(0) | 3405053.2 Ops/sec |
Math.round() | 173029664.0 Ops/sec |
Bitwise: signed round ± to int | 8205285.5 Ops/sec |
Bitwise: UNsigned round ± to int | 174674032.0 Ops/sec |
Math.floor() round down | 173466768.0 Ops/sec |
Math.trunc() round toward zero | 169126608.0 Ops/sec |
Bitwise: round toward zero | 175198432.0 Ops/sec |