Test name | Executions per second |
---|---|
myFloat.toFixed(2) | 1199535.5 Ops/sec |
myFloat.toPrecision(2) | 1188821.2 Ops/sec |
Math.round(myFloat*100.0)/100.0 | 981822.9 Ops/sec |
Bitwise: signed round ± to 2 places | 1311896.2 Ops/sec |
Bitwise: UNsigned round ± to 2 places | 1830831.5 Ops/sec |
myFloat.toFixed(0) | 1209413.4 Ops/sec |
Math.round() | 992171.1 Ops/sec |
Bitwise: signed round ± to int | 1293897.1 Ops/sec |
Bitwise: UNsigned round ± to int | 1832961.4 Ops/sec |
Math.floor() round down | 980852.2 Ops/sec |
Math.trunc() round toward zero | 965362.1 Ops/sec |
Bitwise: round toward zero | 1766974.5 Ops/sec |