Rounding Rules
- If the digit after the rounding position is ≥ 5, round up
- If the digit after is < 5, round down (truncate)
Round to d decimal places: Math.round(x × 10^d) / 10^d
Examples
| Number | Round to | Result |
|---|---|---|
| 3.14159 | 2 decimal places | 3.14 |
| 3.14159 | 4 decimal places | 3.1416 |
| 2564 | Nearest hundred | 2600 |
| 2.6789 | 3 sig. figures | 2.68 |