Order of Operations (PEMDAS and BODMAS): Rules and Examples

Order of operations: 6 + 2 × 3 = 12 and 8 ÷ 2 × 4 = 16

The order of operations is the rule for which part of an expression you calculate first: parentheses, then exponents, then multiplication and division from left to right, then addition and subtraction from left to right. In the US it is remembered as PEMDAS, in the UK as BODMAS and in Canada as BEDMAS. They all mean the same thing. This guide gives the rules, a precedence table, a diagram, worked examples with answers, the viral 8 ÷ 2(2 + 2) puzzle, how Python and Excel handle it, and practice problems.

In this guide
  1. Quick answer
  2. The rules
  3. Diagram
  4. Worked examples
  5. Same-level operations
  6. Negatives and exponents
  7. The 8 ÷ 2(2+2) puzzle
  8. Python, JavaScript and Excel
  9. Common mistakes
  10. Practice problems
  11. FAQ

Order of Operations (PEMDAS / BODMAS): Quick Answer

StepPEMDAS (US)BODMAS (UK)BEDMAS (Canada)What to do
1ParenthesesBracketsBracketsWork inside grouping symbols first
2ExponentsOrders (powers, roots)ExponentsEvaluate powers and roots
3Multiplication and DivisionDivision and MultiplicationDivision and MultiplicationLeft to right, same priority
4Addition and SubtractionAddition and SubtractionAddition and SubtractionLeft to right, same priority

Example: 6 + 2 × 3. Multiplication comes before addition, so 2 × 3 = 6 first, then 6 + 6 = 12. Working left to right instead would wrongly give 24.

In short: Brackets, then powers, then × and ÷ left to right, then + and − left to right.

The Order of Operations Rules, Step by Step

  1. Parentheses (brackets). Simplify inside every pair of grouping symbols first, starting with the innermost. Brackets [ ] and braces { } work the same way. The numerator and denominator of a fraction bar are also grouped.
  2. Exponents (orders). Evaluate powers such as 3² and roots such as √16.
  3. Multiplication and division. Do them in the order they appear, from left to right. Neither one comes first.
  4. Addition and subtraction. Do them from left to right. Neither one comes first.

The key point is that PEMDAS is four levels, not six. Multiplication and division share one level, and addition and subtraction share one level. The letters are only a memory aid.

In short: Same level means left to right. M and D are one step, and A and S are one step.

Diagram: The Four Levels of PEMDAS

Diagram of the order of operations: level 1 parentheses, level 2 exponents, level 3 multiplication and division left to right, level 4 addition and subtraction left to right
The four levels of PEMDAS, BODMAS and BEDMAS. Operations on the same level go left to right.

Worked Examples With Answers

Example: 20 − 8 ÷ 4 + 3. Division first: 8 ÷ 4 = 2. Then left to right: 20 − 2 = 18, and 18 + 3 = 21.

Example: 2 + 3² × 4. Exponent: 3² = 9. Multiplication: 9 × 4 = 36. Addition: 2 + 36 = 38.

Example: 3 × [4 + 2 × (5 − 1)]. Innermost brackets: 5 − 1 = 4. Then 2 × 4 = 8 and 4 + 8 = 12. Finally 3 × 12 = 36.

Example: (12 + 6) ÷ (2 + 1). Brackets: 18 ÷ 3 = 6. As a fraction, (12 + 6)/(2 + 1) = 18/3 = 6.

You can check each answer with the CalcSolver calculator, which follows the same order. For expressions with letters, see algebraic expressions.

Same-Level Operations: Why Left to Right Matters

Many people think multiplication always beats division, because M comes before D in PEMDAS. It does not. They have equal priority, so you go left to right.

ExpressionCorrect (left to right)Common wrong answer
6 ÷ 2 × 36 ÷ 2 = 3, then 3 × 3 = 96 ÷ (2 × 3) = 1
10 − 3 + 210 − 3 = 7, then 7 + 2 = 910 − (3 + 2) = 5
8 ÷ 2 × 48 ÷ 2 = 4, then 4 × 4 = 168 ÷ (2 × 4) = 1

In short: Do × and ÷ in the order you meet them. Do + and − the same way.

Negative Numbers and Exponents

The exponent applies only to the number directly before it. So −3² means −(3²), and the answer is −9. With brackets, (−3)² = (−3) × (−3) = 9.

Repeated exponents are evaluated from the top down. 2^3^2 means 2^(3^2) = 2^9 = 512, not (2^3)^2 = 64.

ExpressionValueWhy
−3²−9Exponent first, then the minus sign
(−3)²9The bracket makes −3 the base
2^3^2512Stacked powers go from the top down
(2^3)^264Brackets change the order

The Viral 8 ÷ 2(2 + 2) Puzzle

Social media often argues over 8 ÷ 2(2 + 2). Brackets first gives 8 ÷ 2 × 4. There are two reasonable readings:

ReadingWorkingAnswer
Implied multiplication ranks the same as ×8 ÷ 2 × 4 = 4 × 416
Implied multiplication binds tighter8 ÷ (2 × 4) = 8 ÷ 81

The puzzle is ambiguous because it is written without enough brackets, not because the rules are unclear. Most calculators and programming languages that treat juxtaposition as ordinary multiplication give 16. Some textbooks and scientific calculators treat implied multiplication as tighter and give 1. The fix is simple: write (8 ÷ 2) × (2 + 2) = 16 or 8 ÷ (2 × (2 + 2)) = 1.

In short: If an expression can be read two ways, add brackets. 8 ÷ 2(2+2) is ambiguous; (8 ÷ 2)(2+2) = 16 and 8 ÷ (2(2+2)) = 1 are not.

Order of Operations in Python, JavaScript and Excel

Computer languages follow the same four levels, with a few quirks that catch people out.

InputResultNote
Python: 8 / 2 * 416.0Left to right. Python division gives a decimal
JavaScript: 8 / 2 * 416Left to right
Python: -3 ** 2-9** binds tighter than a minus sign on its left
Python: 2 ** 3 ** 2512Powers group from the right
Excel: =-3^29Excel applies negation before the exponent
Excel: =2^3^264Excel groups powers from the left

The Excel result for =−3^2 surprises people, because standard maths gives −9. Write =−(3^2) to get −9. The Python table follows the language reference, which says the power operator binds more tightly than a unary operator on its left. Excel lists negation above exponentiation in its precedence table.

Common Mistakes With the Order of Operations

  • Doing all multiplication before all division. 6 ÷ 2 × 3 = 9, not 1.
  • Doing addition before subtraction. 10 − 3 + 2 = 9, not 5.
  • Squaring the minus sign. −3² = −9, but (−3)² = 9.
  • Ignoring the fraction bar. (12 + 6)/(2 + 1) divides the whole top by the whole bottom, giving 6. Writing 12 + 6/2 + 1 gives 16.
  • Ignoring brackets that were never written. In a long expression, add brackets so nobody has to guess.

Order of Operations Practice Problems (With Answers)

1. 7 + 3 × 5

22. 3 × 5 = 15, then 7 + 15 = 22.

2. 36 ÷ 6 × 2

12. Left to right: 36 ÷ 6 = 6, then 6 × 2 = 12.

3. 4 × (9 − 3)² ÷ 6

24. Brackets: 9 − 3 = 6. Exponent: 6² = 36. Then 4 × 36 = 144 and 144 ÷ 6 = 24.

4. 50 − 2 × 3² + 4

36. 3² = 9, then 2 × 9 = 18, then 50 − 18 = 32 and 32 + 4 = 36.

5. −4² + 10

−6. −4² = −16, and −16 + 10 = −6.

6. (15 + 5) ÷ (3 − 1)

10. 20 ÷ 2 = 10.

Order of Operations: FAQ

What is the order of operations?

The order of operations is the set of rules for evaluating an expression: parentheses first, then exponents, then multiplication and division from left to right, then addition and subtraction from left to right.

What is the difference between PEMDAS and BODMAS?

There is no difference in the result. PEMDAS (US) and BODMAS (UK) name the same four levels. BODMAS says “orders” for powers and roots, and lists division before multiplication, but the two share a level.

Does multiplication come before division?

No. Multiplication and division have equal priority, so you work from left to right. 6 ÷ 2 × 3 = 9.

What is 8 ÷ 2(2 + 2)?

It is ambiguous. If implied multiplication is treated like ordinary multiplication the answer is 16. If it binds tighter the answer is 1. Add brackets to make it clear.

Why does Excel give a different answer for -3^2?

Excel applies negation before exponentiation, so =-3^2 returns 9. In standard maths −3² is −9. Use =-(3^2) to get −9.

How do I check my answer?

Enter the whole expression in a calculator that follows the standard order, or work it by hand and mark each step.

Sources and Further Reading

Every answer on this page was checked by computer. For more speed, try mental math tricks, learn algebra basics and use the CalcSolver calculator.

Check your working in seconds

Type any problem from this guide into the free CalcSolver calculator and see the answer, with fractions, instantly.