Why calculators disagree on the order of operations

Why 6÷2(1+2) gives 9 or 1, why -3^2 can be -9 or 9, and what the percent key really does, with the rules each kind of calculator follows.

On this page

Type 6÷2(1+2) into two calculators and you may get 9 on one and 1 on the other. Type -3^2 into a calculator and a spreadsheet and you may get −9 and 9. Press 50 + 10 % on a shop calculator and it says 55, while a scientific one says 50.1. None of these machines is broken. Each follows a rule, and the rules differ in a few specific places: implied multiplication, the leading minus sign, the percent key and whether the calculator waits for the whole expression at all. This article goes through each one, shows the reasoning, and explains which reading the scientific calculator on this site uses. Every result quoted for it was produced with its own parser.

The part everyone agrees on

The core order is not in dispute. Brackets first, then powers, then multiplication and division, then addition and subtraction. Operations of the same rank are done from left to right:

  • 2+3×4 is 14, because the multiplication comes first. (2+3)×4 is 20.
  • 10-4-3 is 3: (10 − 4) − 3, never 10 − (4 − 3).
  • 100/10/5 is 2: (100 ÷ 10) ÷ 5.

The mnemonics (PEMDAS, BODMAS, BIDMAS) all describe this, and they share one weakness: they list "M" before "D" or "D" before "M", which makes people think multiplication beats division. It does not. They are the same rank, done left to right, and so are addition and subtraction.

Calculators that do not wait

The cheapest disagreement comes from basic four-function calculators, including many phone calculators in their simple mode. They work in immediate execution: each time you press an operator, the result so far is calculated. Press 2 + 3 × 4 = and the machine computes 2 + 3 = 5 when you press ×, then 5 × 4 = 20. It never saw the whole expression, so it could not apply precedence.

A scientific calculator, a spreadsheet and a programming language read the whole expression first and give 14. If you need to check a sum done on a basic calculator, redo it step by step in the order it was keyed, not in mathematical order.

Implied multiplication: 6÷2(1+2)

This is the famous one. Read strictly by the rules above, 2(1+2) is just 2 × (1 + 2), and multiplication and division go left to right:

6 ÷ 2 × 3 = 3 × 3 = 9

But many people, and some calculators, treat a number written directly against a bracket as more tightly bound than an explicit ×: 2(1+2) is read as a single block, as it would be in algebra where 1/2x usually means 1/(2x). That reading gives:

6 ÷ (2 × 3) = 6 ÷ 6 = 1

Neither convention is "the law". Mathematical writing usually avoids the question by using a fraction bar, which makes the grouping visible. On a single line of text there is no fraction bar, so the only safe habit is to write the brackets you mean.

This site's calculator treats implied multiplication exactly like ×, left to right, so 6÷2(1+2) is 9 and 6÷(2(1+2)) is 1. The same rule applies to constants: 1/2pi is (1/2) × π = 1.5707963267949, while 1/(2pi) is 0.159154943091895. When you divide by a product, put the product in brackets.

The leading minus: -3^2

In written mathematics, −3² means −(3²) = −9: the exponent applies to the 3, and the minus sign is applied afterwards. Most scientific calculators and programming languages that have a power operator follow this. Spreadsheets are the well-known exception: in Excel and many similar programs, =-3^2 returns 9, because the negation is applied to the 3 before the power. Microsoft documents this order; it is a rule, not a bug, but it surprises people moving formulas between tools.

This calculator follows the mathematical reading:

  • -3^2 = −9
  • (-3)^2 = 9
  • 2^-2 = 0.25 (a minus sign right after ^ belongs to the exponent)

Powers also group from the right: 2^3^2 is 2^(3^2) = 2^9 = 512, not (2^3)^2 = 64. Stacked exponents in printed maths are read top-down, and the calculator does the same.

The percent key

On most basic and shop calculators, % is not a number at all but an instruction that depends on the operation before it. 50 + 10 % means "add 10 % of 50", so the display shows 55. 50 − 10 % gives 45. This is convenient for prices and useless for anything else, because the same key means different things in different positions.

On this scientific calculator, % simply means "divide by 100", wherever it appears:

  • 200×15% = 30 (15 % of 200)
  • 50+10% = 50.1 (50 + 0.1)
  • 50*(1+10%) = 55 (50 increased by 10 %)

If you want the shop-calculator result, write it as the last line: multiply by (1 + the percentage). For the reverse problem, finding what percentage one number is of another, the percentage calculator shows the formula it used.

Postfix operators and functions

Factorial and percent sit right after a number and bind tighter than anything else, including powers and the leading minus:

  • 3!^2 = (3!)² = 36, and 2^3! = 2^(3!) = 64
  • -3! = −(3!) = −6

Function names need brackets here: sin(30), not sin 30. Some calculators accept sin 30^2 and must decide whether that is sin(30²) or (sin 30)²; requiring brackets removes the question. The angle unit is another source of "wrong" answers: sin(90) is 1 in degrees and 0.893996663600558 in radians. Check the DEG/RAD setting before blaming the order of operations.

Precision is a separate issue

Some disagreements are not about order at all. Computers store numbers in binary, so 0.1 and 0.2 cannot be stored exactly, and 0.1 + 0.2 is really 0.30000000000000004. A calculator that shows 15 significant digits displays 0.3; a programming console shows the long version. The same goes for sin(pi) in radians: π itself is rounded, so the result is 1.22464679914735e-16 rather than 0. That is correct for the rounded π, not a mistake in the order of operations.

Common mistakes

  • Trusting the mnemonic's letter order. Multiplication does not come before division, nor addition before subtraction. Same rank, left to right.
  • Dividing by an implied product. 1/2x and 6÷2(1+2) mean different things on different machines. Add brackets.
  • Squaring a negative number without brackets. -3^2 is −9 on a calculator and 9 in a spreadsheet. (-3)^2 is 9 everywhere.
  • Using the % key for a price increase on a scientific calculator. It gives 50.1, not 55. Multiply by 1.1 instead.
  • Forgetting the angle mode. A trigonometry answer that looks absurd is usually in the wrong unit.
  • Re-checking a basic calculator's result with precedence. It worked left to right as you pressed the keys; redo it the same way.

The scientific calculator states its rules on the page, shows the answer as you type and points at the position of any error, so you can see exactly how an expression was read before you trust the result.

Tools mentioned in this article

Back to the blog