Math.round(n) vs Bitwise n + (n < 0 ? -0.5 : 0.5)>>0Fastest: Bitwise n + (n < 0 ? -0.5 : 0.5)>>0 (1.2x faster)
65,279,460 ops/sec
52,342,120 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| Math.round(n) | |
| Bitwise n + (n < 0 ? -0.5 : 0.5)>>0 |
| Test name | Executions per second |
|---|---|
| ✓ Math.round(n) | 274,273,184 Ops/sec |
| Bitwise n + (n < 0 ? -0.5 : 0.5)>>0 | 169,586,400 Ops/sec |