the tie that separates the rules
- Number
- 2.5
- Decimal places
- 0
- Rounding rule
- Half away from zero (what most people mean)
Rounded3
The definitional disagreement between the two half rules
Open this exampleRounding under all four common rules at once, because they disagree on exactly the values people check. The difference only shows up on a tie, and a column of ties is where a total drifts.
Also called: round to decimal places, banker rounding.
2.5 rounds to 3 at 0 decimal places. Ties go away from zero, which is the rule taught in school. The other rules would give half away 3, half even 2, up 3, down 2.
Every rule agrees except when the digit being dropped is exactly five. Half away from zero is what school taught and what most people expect. Half to even, called banker's rounding, sends ties to the nearest even digit so a long column does not drift upwards; it is the default in most spreadsheet and floating-point standards, which surprises people. Always up and always down never look at the tie at all.
scale by ten to the decimal places, round, scale back; the tie rule is what variesEach of these is asserted on every build. If a change to the engine ever moved one of these answers, the build would fail before the page could print it.
Rounded3
The definitional disagreement between the two half rules
Open this exampleRounded-3
boundary: JavaScript's own Math.round gives -2 here, which is the bug this avoids
Open this exampleRounded2
degenerate case: away from a tie all rules agree
Open this exampleFormula version 1.0.0 · definition 1.0.0 · India · Report a problem with this calculator