Rounding, Truncating, Rounding Up and the 0.1 + 0.2 Problem — All About Rounding in Calculators
The difference between rounding, truncating (rounding down) and rounding up, rounding money to whole units, banker's rounding, why 0.1 + 0.2 becomes 0.30000000000000004 on a computer, and how this calculator handles it.
Percentage calculations involve a lot of division and decimal multiplication, so the last digits rarely come out even. For the same calculation, how you handle the leftover digits can change the result by a few cents or a few units of currency, so knowing the rules helps you explain differences between receipts and quotes.
Three ways to handle leftover digits
- Round: if the digit being dropped is 5 or more, round up; otherwise drop it. 1,234.5 → 1,235
- Truncate (round down): drop all the digits being discarded. 1,234.9 → 1,234
- Round up: if the digits being dropped are not zero, round up. 1,234.1 → 1,235
You can also change the unit. Truncating 12,345 to the nearest 10 gives 12,340, and rounding it to the nearest 100 gives 12,300.
What is used where
- VAT amount: in South Korea, truncating fractions of a won is common practice
- National tax payments: in South Korea, fractions under 10 won are not counted under Article 47 of the National Treasury Management Act
- Store sale prices: it varies by store, but discounts are often truncated to units of 10 or 100
- Statistics and published rates: rounding to one or two decimal places is typical
- Required quantities (boxes, people): you cannot come up short, so round up
Rounding negative numbers
Does −2.5 round to −3 or −2? This calculator rounds away from zero, giving −3. Truncation goes toward zero (−1.239 → −1.23) and rounding up goes away from zero. The same rule is applied to the size (absolute value) of the amount regardless of its sign.
Banker's rounding
This method sends exact halves (…5) to the even side (2.5 → 2, 3.5 → 4). It is used in some accounting and programming environments to reduce the bias that builds up when rounding is repeated many times. Everyday arithmetic and this calculator use ordinary rounding.
Why is 0.1 + 0.2 equal to 0.30000000000000004 on a computer?
Computers store numbers in binary. Just as 1/3 in decimal never ends (0.333…), 0.1 is a never-ending fraction in binary, so it cannot be stored exactly and is stored as a very close rounded value. That is why most languages, including JavaScript, give 0.30000000000000004 for 0.1 + 0.2.
For the same reason, the common way to round 1.005 to two decimal places (toFixed(2)) returns 1.00, not 1.01, because 1.005 is actually stored as 1.00499999….
How this calculator handles it
- Every intermediate result is cleaned up at 12 significant digits to remove binary representation noise. 0.1 + 0.2 → 0.3
- Rounding shifts the decimal places using decimal exponent notation rather than multiplying the number. 1.005 → 1.01, 2.675 → 2.68
- For amounts, you can choose the unit (1, 10, 100, etc.) and the method (truncate, round, round up) in the Discount and VAT tabs.
- This approach was verified with node unit tests on edge cases (1.005, −2.5, very small and very large values).
Displayed digits vs actual value
The Decimals setting at the top only changes how many digits are displayed. 1 ÷ 3 × 100 is 33.3333333333 internally and appears as 33.33 with two decimals. The Copy button copies the value shown on screen.
Summary
When different rounding rules make results differ by a few units, that is not an error but a difference in rules. When amounts do not match, first check ① at which step the rounding was applied and ② which unit and method were used.