
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
Order of Operations (PEMDAS / BODMAS): Quick Answer
| Step | PEMDAS (US) | BODMAS (UK) | BEDMAS (Canada) | What to do |
|---|---|---|---|---|
| 1 | Parentheses | Brackets | Brackets | Work inside grouping symbols first |
| 2 | Exponents | Orders (powers, roots) | Exponents | Evaluate powers and roots |
| 3 | Multiplication and Division | Division and Multiplication | Division and Multiplication | Left to right, same priority |
| 4 | Addition and Subtraction | Addition and Subtraction | Addition and Subtraction | Left 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
- 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.
- Exponents (orders). Evaluate powers such as 3² and roots such as √16.
- Multiplication and division. Do them in the order they appear, from left to right. Neither one comes first.
- 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

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.
| Expression | Correct (left to right) | Common wrong answer |
|---|---|---|
| 6 ÷ 2 × 3 | 6 ÷ 2 = 3, then 3 × 3 = 9 | 6 ÷ (2 × 3) = 1 |
| 10 − 3 + 2 | 10 − 3 = 7, then 7 + 2 = 9 | 10 − (3 + 2) = 5 |
| 8 ÷ 2 × 4 | 8 ÷ 2 = 4, then 4 × 4 = 16 | 8 ÷ (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.
| Expression | Value | Why |
|---|---|---|
| −3² | −9 | Exponent first, then the minus sign |
| (−3)² | 9 | The bracket makes −3 the base |
| 2^3^2 | 512 | Stacked powers go from the top down |
| (2^3)^2 | 64 | Brackets 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:
| Reading | Working | Answer |
|---|---|---|
| Implied multiplication ranks the same as × | 8 ÷ 2 × 4 = 4 × 4 | 16 |
| Implied multiplication binds tighter | 8 ÷ (2 × 4) = 8 ÷ 8 | 1 |
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.
| Input | Result | Note |
|---|---|---|
| Python: 8 / 2 * 4 | 16.0 | Left to right. Python division gives a decimal |
| JavaScript: 8 / 2 * 4 | 16 | Left to right |
| Python: -3 ** 2 | -9 | ** binds tighter than a minus sign on its left |
| Python: 2 ** 3 ** 2 | 512 | Powers group from the right |
| Excel: =-3^2 | 9 | Excel applies negation before the exponent |
| Excel: =2^3^2 | 64 | Excel 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
- Math is Fun, Order of Operations: PEMDAS.
- OpenStax, Prealgebra 2e, Section 2.1: Use the Language of Algebra (simplify expressions using the order of operations), Rice University.
- Python Software Foundation, The Python Language Reference: Expressions (the power operator and unary operators).
- Microsoft Support, Calculation operators and precedence in Excel.
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.


