The order of operations (PEMDAS)
- Parentheses (brackets): work out the innermost ones first.
- Exponents: powers and roots. A stack of powers goes from the top down, so 2^3^2 = 2^9.
- Multiplication and Division, together, from left to right.
- Addition and Subtraction, together, from left to right.
BODMAS and BEDMAS are the same rules with different names (Brackets, Orders or Exponents). The key point people miss is the pairs: multiplication doesn't come before division, and addition doesn't come before subtraction. Whichever comes first, reading left to right, goes first.
8 ÷ 4 × 2 = 2 × 2 = 4 (not 8 ÷ 8 = 1)
−3^2 = −(3^2) = −9, but (−3)^2 = 9
Worked example
2 × (3 + 4) − 8 ÷ 4:
- Parentheses: 3 + 4 = 7, giving 2 × 7 − 8 ÷ 4.
- Multiply and divide, left to right: 2 × 7 = 14, then 8 ÷ 4 = 2, giving 14 − 2.
- Subtract: 14 − 2 = 12.
What about 6 ÷ 2(1 + 2)?
Following PEMDAS strictly, the brackets give 3, then 6 ÷ 2 × 3 is done left to right: 3 × 3 = 9. Some people and some calculators treat implied multiplication, like 2(3), as binding tighter than ÷, which gives 6 ÷ 6 = 1. Both conventions exist, which is why the expression is ambiguous. Writing (6 ÷ 2)(1 + 2) or 6 ÷ (2(1 + 2)) removes the doubt. This calculator uses strict left to right and flags the case.
Limitations
- Fractions stay exact: 1/3 + 1/6 is shown as 1/2, not 0.4999…. Roots and fractional powers, like 2^0.5, are shown as decimals.
- Only + − × ÷ ^ and brackets are supported. For sin, log and the rest, use the scientific calculator.
- A minus sign in front of a number is applied after exponents, as in algebra and Python: −3^2 = −9.
More examples and the reasons behind the rules are in the order of operations guide.