%PercentLab

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.

Try it in the calculator →

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

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

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

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.

Try it in the calculator →