Tutorials

Order of Operations and Why 0.1 + 0.2 Looks Wrong

Two things surprise people who use calculators. The answer changes with the order you type. And some decimals show odd extra digits. Both have easy explanations.

Order of operations

In school maths multiplication and division come before addition and subtraction. So 2 + 3 × 4 is 14. Many pocket calculators just work through your entries one at a time and give 20. The Basic Calculator on this site does it that way. If you want the school answer do the multiplication first and then add.

Why 0.1 + 0.2 can look wrong

Computers store most decimals in binary. A number like 0.1 can't be stored exactly in binary just like one third can't be written exactly in decimal. Add 0.1 and 0.2 in JavaScript and many other languages and you get 0.30000000000000004. The gap is tiny and won't matter day to day but you can see it when nothing rounds the answer.

What our calculator does

It rounds results to 12 significant digits. So 0.1 + 0.2 shows as 0.3. That hides the harmless error in everyday sums. It doesn't make this a tool for work that needs exact decimals like accounting. Software for that uses special methods.

Zero and long numbers

Dividing by zero has no answer so the calculator shows a message. Entries stop at 15 digits to keep the display readable. For percentage questions like discounts try the Percentage Calculator which labels each type of question.