🇺🇸 USC
Math & Conversion
🧠

Order of Operations Calculator

Solve any expression with PEMDAS and see every step

Last updated September 6, 2026

Method: The expression is tokenized and parsed with the shunting-yard algorithm, then reduced one operation at a time in standard PEMDAS order: innermost parentheses first, exponents right to left, multiplication and division left to right on one tier, then addition and subtraction left to right on one tier.

Included: Plus, minus, times, divide and power, round parentheses at any nesting depth, decimals, negative numbers, a numbered step list, and the left-to-right answer shown side by side so you can see when the order actually matters.

Not included: Variables and algebraic simplification, implied multiplication such as 2(3 + 4), factorials, trigonometric and logarithmic functions, and exact fraction output. Values are computed in double-precision floating point.

Try an example

🧠 PEMDAS result

20
8 + 12 / 4 * (3 - 1)^2
Steps taken
6
Deepest nesting
1 level
Exponents applied
1
Times / divides
2
⚠️

Working left to right gives a different answer

Solved strictly left to right (parentheses still first), this expression comes out as 100 instead of the correct 20. That gap is exactly what PEMDAS prevents.

📋 Step by step

1Subtraction (left to right)3 − 1 = 2
8 + 12 ÷ 4 × (3 − 1) ^ 2
= 8 + 12 ÷ 4 × (2) ^ 2
2Parenthesesthe group is a single value, drop the brackets
8 + 12 ÷ 4 × (2) ^ 2
= 8 + 12 ÷ 4 × 2 ^ 2
3Exponents (right to left)2 ^ 2 = 4
8 + 12 ÷ 4 × 2 ^ 2
= 8 + 12 ÷ 4 × 4
4Division (left to right)12 ÷ 4 = 3
8 + 12 ÷ 4 × 4
= 8 + 3 × 4
5Multiplication (left to right)3 × 4 = 12
8 + 3 × 4
= 8 + 12
6Addition (left to right)8 + 12 = 20
8 + 12
= 20

🔤 The PEMDAS order used here

TierOperationDirection
PParentheses, innermost group firstinside out
EExponents and rootsright to left
MDMultiplication and division, one tierleft to right
ASAddition and subtraction, one tierleft to right

A leading minus sign is treated as negation applied after the power, so −4^2 is −16 while (−4)^2 is 16.

Exact arithmetic, standard conventions. The expression is parsed with the shunting-yard method and reduced one operation at a time in PEMDAS order. Results use double-precision floating point, so long decimal chains can differ in the last digit or two.

Order of operations: the complete guide

An order of operations calculator applies PEMDAS to an expression and shows each reduction in turn. Take 8 + 12 / 4 * (3 - 1)^2: the correct value is 20, reached in six steps. Read the same expression straight from left to right and you get 100, an answer that is off by a factor of five.

Three neighboring tools cover adjacent questions. The Scientific Calculator adds trigonometry, logarithms and memory keys once you need functions rather than a step trace, the Exponent Calculator goes deep on a single power including negative and fractional exponents, and the Fraction Calculator keeps results as exact fractions instead of decimals. Use this page when the question is not what the arithmetic is but in which order it has to happen.

What PEMDAS actually says

PEMDAS is a memory aid for the priority order that mathematicians, textbooks and programming languages all share. Written as a rule it looks like this:

P → E → M and D (left to right) → A and S (left to right)

The single most common misreading is treating those six letters as six separate stages. They are four tiers. Multiplication and division rank equally and run left to right in whatever order they appear, and addition and subtraction rank equally and do the same. The acronym has to spell something pronounceable, so it lists M before D and A before S, but that ordering carries no meaning at all.

Two further conventions round the rule out. Parentheses are resolved from the innermost group outward, and exponents group from the right, so a stack of powers is evaluated top down. Everything the calculator on this page does follows from those four tiers plus those two conventions.

A fully worked example, step by step

Here is the default expression 8 + 12 / 4 * (3 - 1)^2 taken apart exactly the way the calculator does it. Each row shows one operation and the expression that is left afterwards.

Step Rule Work What remains
1 Inside parentheses 3 − 1 = 2 8 + 12 ÷ 4 × (2) ^ 2
2 Parentheses the group is one value, drop the brackets 8 + 12 ÷ 4 × 2 ^ 2
3 Exponents (right to left) 2 ^ 2 = 4 8 + 12 ÷ 4 × 4
4 Division (left to right) 12 ÷ 4 = 3 8 + 3 × 4
5 Multiplication (left to right) 3 × 4 = 12 8 + 12
6 Addition (left to right) 8 + 12 = 20 20

Notice what happens at step 4. Both a division and a multiplication are waiting, and the division wins simply because it stands further left. Had the multiplication gone first, the intermediate value would have been 12 / 16, and the final answer would have been 8.75 instead of 20.

A second example: negatives and decimals

Signs and decimal points do not create a new tier, but they do trip people up. Take -3^2 + 4.5 * 2. The power is evaluated first, giving 9. Only then is the minus sign applied, turning it into negative 9. The multiplication 4.5 × 2 = 9 follows, and the final addition gives -9 + 9 = 0. Four steps, and the answer is exactly zero.

Read the same string left to right and you would negate the 3 first, square negative 3 to get 9, add 4.5 to get 13.5 and double it to 27. Two answers, one string of characters, and the whole difference is the convention that a power binds more tightly than a leading minus sign. If you actually mean the square of negative three, write (-3)^2 and the parentheses settle it.

Ten expressions solved both ways

The table compares the correct PEMDAS value with the value you would get by evaluating strictly left to right (parentheses still first). Where the two columns agree, the expression is unambiguous. Where they differ, the order of operations is doing real work.

Expression PEMDAS Left to right Why
2 + 3 * 4 14 20 Multiply before you add
(2 + 3) * 4 20 20 Parentheses force the addition first
8 - 2 * 3 + 1 3 19 Only the product jumps the queue
6 / 2 * 3 9 9 Same tier, so left to right either way
2^3^2 512 64 Powers group right to left
-4^2 -16 16 The power beats the minus sign
(-4)^2 16 16 Parentheses attach the sign to the 4
1.5 * 4 - 2.25 / 0.5 1.5 7.5 Decimals follow the same tiers
3 + 6 * (5 + 4) / 3 - 7 14 20 Group, then times and divide, then add
2 * (3 + 5)^2 / 4 32 64 The power applies to the group only

Three of the ten rows agree. That is the useful lesson: the order of operations is not a tax on every calculation, it is a tie-breaker that only fires when tiers are mixed.

Where the parentheses go changes everything

The same five numbers and the same three operators produce five different answers depending on how they are grouped. Every value below was computed with the calculator on this page.

Expression Result What the grouping does
12 - 6 / 3 + 1 11 Division only, then left to right
(12 - 6) / 3 + 1 3 The subtraction is promoted
12 - 6 / (3 + 1) 10.5 The divisor becomes 4
(12 - 6) / (3 + 1) 1.5 Both sides are grouped
12 - (6 / 3 + 1) 9 The whole tail is subtracted

The spread runs from 1.5 to 11, a factor of more than seven, and nothing changed except two brackets. This is why any expression that will be read by someone else is worth over-punctuating.

How to use this calculator

  1. Type the expression into the box using digits, the operators plus, minus, star, slash and caret, and round parentheses. Spaces are optional.
  2. Use * for multiplication and ^ for a power. The letter x, the times sign and the divide sign are also accepted, and square brackets are read as parentheses.
  3. Read the headline answer at the top of the blue card. Beneath it you get the number of steps, the deepest level of nesting, and how many powers and products were involved.
  4. Compare the two answers. The card underneath shows what the same expression would come to if you ignored precedence and worked left to right. If the two match, the expression was never ambiguous.
  5. Walk the step list. Each numbered card names the rule being applied, the single arithmetic fact used, the expression before, and the expression after.
  6. Tap a preset to load one of the classic tricky expressions if you would rather check your understanding than type your own.

Everything recalculates as you type, so you can add a bracket and watch the answer move without pressing anything.

Who this calculator is for

  • Students in grades 5 through 9 checking homework, where the step list matters more than the answer because the teacher grades the working.
  • Parents and tutors who need to explain why the answer is what it is rather than simply assert it.
  • Teachers building worked examples and looking for expressions where left to right and PEMDAS visibly disagree.
  • Test takers preparing for the SAT, ACT, GED or a placement exam, where a single misplaced product costs a whole question.
  • Programmers and spreadsheet users checking that a formula they wrote on one line groups the way they intended before it goes into production.
  • Anyone settling an argument about one of the expressions that circulate on social media every few months.

Key terms explained

  • Operand: a value an operator acts on. In 12 / 4 the operands are 12 and 4.
  • Operator: the symbol that combines operands, here plus, minus, star, slash and caret.
  • Precedence: the tier an operator belongs to. Higher precedence is applied first.
  • Associativity: the direction used when two operators of equal precedence meet. Times and divide associate left, powers associate right.
  • Unary minus: a minus sign with nothing to its left, meaning negation rather than subtraction.
  • Nesting depth: how many parentheses are open at the deepest point of the expression.
  • Shunting-yard algorithm: the standard parsing method that turns an expression written in ordinary infix notation into a structure a machine can evaluate in the correct order.

Multiplication and division share one tier

This is the rule that costs the most marks. In 6 / 2 * 3 the division happens first, because it is written first, giving 3 × 3 = 9. Reading the D of PEMDAS as an instruction to divide before you multiply produces 6 / 6 = 1 instead. The identical trap sits in the A and the S: 10 - 4 + 2 is 8, because the subtraction is on the left, and not 4 as you would get by adding first.

A useful way to keep this straight is to rewrite every subtraction as adding a negative and every division as multiplying by a reciprocal. Once you do, the left-to-right rule becomes obvious, because addition and multiplication can be reordered freely while their inverses cannot.

Exponent towers group from the right

Powers are the exception to left-to-right within a tier. 2^3^2 means 2 raised to the power of 3 squared, that is 2 to the ninth, which is 512. Grouping the other way would give 8 squared, which is 64. The right-to-left convention exists because the left-to-right reading is redundant: a power of a power can already be written by multiplying the exponents, so the notation is reserved for the reading that cannot be written more simply.

The minus sign is two different things

A minus sign between two values is subtraction. A minus sign with nothing to its left, or sitting right after another operator or an opening bracket, is negation. This calculator handles both, and it follows the standard convention that negation is applied after the exponent, so -4^2 is -16 while (-4)^2 is 16.

Popular spreadsheet software is the best-known exception: it treats the leading minus as part of the number and returns 16 for the same input. Neither is a mistake exactly, they are different conventions, but it means a formula copied from a spreadsheet into a programming language can silently change value. Add the parentheses and the ambiguity disappears in both.

Fraction bars and radicals are hidden parentheses

Textbook notation carries grouping that vanishes when you type an expression on one line. A horizontal fraction bar groups everything above it and everything below it, so a fraction with numerator 3 + 5 and denominator 2 + 2 must be typed as (3 + 5) / (2 + 2), which equals 2. Type 3 + 5 / 2 + 2 and only the 5 is divided, giving 7.5. A radical sign does the same job for everything under the bar, and an exponent written as a raised numeral groups its whole expression. Whenever you move mathematics from a page onto a keyboard, put the invisible groupings back in explicitly.

PEMDAS, BODMAS and BIDMAS

The acronym changes with the country but the rule does not. American classrooms teach PEMDAS, often through the sentence "Please Excuse My Dear Aunt Sally". Much of the Commonwealth teaches BODMAS, where B is brackets and O is orders, and BIDMAS uses indices for the same idea. BODMAS lists division before multiplication, which looks like a contradiction until you remember that both sit on one tier and are worked left to right regardless. Any two people applying any of the three acronyms correctly will always land on the same number.

What changes the result the most

  • Parentheses: by far the largest lever. Moving one bracket in the table above swung the answer from 1.5 to 11.
  • Mixing tiers: an expression that mixes addition with multiplication or a power is where precedence decides the value. An expression built from one tier is order-proof.
  • The position of a division: because the tier runs left to right, sliding a division one operator to the left or right can change everything after it.
  • A leading minus in front of a power: flips the sign of the whole term and is the single most common source of a wrong sign.
  • Stacked exponents: rare in everyday arithmetic, but when they appear the right-to-left grouping produces enormous differences, 512 against 64 in a two-symbol example.

Practical tips

  • Bracket anything you want a reader to be sure about. Redundant parentheses cost nothing and remove every argument.
  • Underline or box each tier as you go when working on paper, so you never lose track of which operation is next.
  • Estimate before you calculate. Knowing the answer should be near 20 makes an accidental 100 obvious immediately.
  • Rewrite subtraction as adding a negative when an expression has several minus signs in a row.
  • Check a spreadsheet formula in both directions, especially any formula that starts with a minus in front of a power.
  • Work the innermost bracket first, always, and rewrite the whole expression after each step rather than editing in place.

Limitations and assumptions

  • The calculator handles arithmetic only. There are no variables, no equation solving and no symbolic simplification.
  • Implied multiplication is rejected. Type the star: 2 * (3 + 4), not 2(3 + 4). This is deliberate, because expressions such as 8 / 2(2 + 2) are read differently by different conventions.
  • Functions such as sine, cosine, logarithm, absolute value and factorial are not supported. Use the Scientific Calculator for those.
  • Results are decimal, not exact fractions. One third shows as a long decimal rather than as a fraction.
  • Arithmetic uses double-precision floating point, so a long chain of decimal operations can differ from a hand calculation in the last digit or two.
  • A power with no real value, such as a negative base with a fractional exponent, and any division by zero are reported as errors rather than shown as a number.

How it compares to related calculators

This page answers "in what order does this expression get evaluated, and why". Other questions have better-suited tools:

Sources

Everything on this page is deterministic arithmetic and definitional convention rather than data, so there are no statistics to cite. The rules applied here are the standard ones:

  • The four precedence tiers (grouping, exponentiation, multiplicative, additive) and the left-to-right associativity of the multiplicative and additive tiers are the conventional definition used in mathematics and in every mainstream programming language.
  • Right associativity of exponentiation is the standard convention, so a^b^c means a^(b^c).
  • Unary minus applied after exponentiation is the standard mathematical reading, which is why -4^2 is -16.
  • The shunting-yard parsing method is the classical algorithm for converting infix expressions to an evaluation order.
  • Every worked example, every step list and every number in the tables above was computed with this calculator's own engine and verified independently before publication.

⚠️ Common mistakes & edge cases

Treating PEMDAS as six separate steps

It is four tiers, not six. Multiplication and division are one tier, addition and subtraction are another. In 6 / 2 * 3 the division goes first because it stands further left, giving 9, not 1.

Adding before subtracting

10 - 4 + 2 equals 8, not 4. The subtraction is on the left, so it runs first. The A before the S in the acronym is there for pronunciation, not for priority.

Squaring the minus sign by accident

-4^2 is -16, because the exponent is applied before the negation. Only (-4)^2 gives 16. Spreadsheets read the first form the other way, so never copy such a formula between tools without adding brackets.

Losing the invisible brackets of a fraction bar

A fraction bar groups its whole numerator and its whole denominator. Typing 3 + 5 / 2 + 2 gives 7.5, while the fraction it was meant to represent is (3 + 5) / (2 + 2) = 2.

Working an exponent tower from the left

2^3^2 is 512, not 64. Powers group from the right, so the top exponent is evaluated first. This is the only place inside the order of operations where the direction reverses.

Relying on implied multiplication

Expressions such as 8 / 2(2 + 2) go viral precisely because there is no universal rule for a product written without a symbol. Type the star and the ambiguity is gone before it starts.

Note: When an expression will be read by someone else, extra parentheses are free. The goal is not the shortest expression, it is the one nobody can misread.

❓ Frequently asked questions

What does PEMDAS stand for?

PEMDAS stands for Parentheses, Exponents, Multiplication and Division, Addition and Subtraction. It is the agreed order in which the operations inside an expression are carried out. The two middle pairs are single tiers, not four separate steps: multiplication and division rank equally and are done left to right, and so are addition and subtraction.

Is multiplication always done before division?

No. Multiplication and division sit on the same tier and are performed from left to right in the order they appear. In 6 / 2 * 3 the division comes first because it is further left, giving 3 * 3 = 9. If you did the multiplication first you would get 6 / 6 = 1, which is wrong. The same left-to-right rule applies to addition and subtraction.

Why is 8 + 12 / 4 * (3 - 1)^2 equal to 20?

Work inside the parentheses first: 3 - 1 = 2. Then the exponent: 2^2 = 4. Then multiplication and division left to right: 12 / 4 = 3, then 3 * 4 = 12. Finally the addition: 8 + 12 = 20. Solving the same expression strictly left to right would give 100, which shows how much the order matters.

What is the difference between PEMDAS and BODMAS?

They are the same rule under different names. PEMDAS is the American acronym (Parentheses, Exponents, Multiplication and Division, Addition and Subtraction) and BODMAS is common in the UK and elsewhere (Brackets, Orders, Division and Multiplication, Addition and Subtraction). BIDMAS swaps Orders for Indices. All three describe an identical order because division and multiplication share one tier, as do addition and subtraction.

Why does this calculator say -4^2 is -16?

By standard convention the exponent binds more tightly than the minus sign, so -4^2 means the negative of 4^2, which is -16. To square the negative number itself you must write the parentheses: (-4)^2 = 16. Spreadsheet programs are a well-known exception and return 16 for -4^2, which is why the parentheses are always worth typing.

How does the calculator handle nested parentheses?

It always evaluates the innermost complete group first, then works outward. In 7 + 3 * (10 / (12 / (3 + 1) - 1)) the deepest group 3 + 1 = 4 is resolved first, then 12 / 4 - 1 = 2, then 10 / 2 = 5, then 3 * 5 = 15 and finally 7 + 15 = 22. The step list shows each of those reductions in order.

What happens with a tower of exponents like 2^3^2?

Exponents are evaluated right to left, so 2^3^2 means 2^(3^2) = 2^9 = 512, not (2^3)^2 = 64. This right-to-left grouping is the one place inside PEMDAS where the direction is not left to right. If you want the other reading, add parentheses.

Does this calculator accept decimals and negative numbers?

Yes. Decimal values such as 1.5 or 0.25 and negative values such as -7 work anywhere a number can appear, including inside parentheses and as an exponent. A minus sign directly after an operator or an opening parenthesis is read as a negative sign rather than as subtraction, so 8 / -2 and 2^-3 both evaluate correctly.

Which symbols can I type into the expression box?

Digits, a decimal point, the operators + - * / and ^ for powers, and round parentheses. The letter x and the symbols multiplication sign and division sign are accepted as multiplication and division, square brackets are read as parentheses, and ** is read as ^. Anything else returns a message naming the character that was not understood.

Why does the calculator refuse 2(3 + 4)?

Because implied multiplication is genuinely ambiguous once other operators are involved, this calculator asks for the operator to be written out: type 2 * (3 + 4) instead. Expressions such as 8 / 2(2 + 2) are famous internet arguments precisely because different conventions read the implied product differently. Writing the star removes all doubt.

Does the order of operations change the answer for every expression?

No. Some expressions give the same value in any order, for example 6 / 2 * 3 or 10 - 4 + 2, because every operation sits on one tier. The order only matters when tiers are mixed, such as an addition next to a multiplication or a power. The calculator shows the left-to-right answer alongside the PEMDAS answer so you can see immediately whether the expression is one of the ambiguous ones.

Is a fraction bar the same as a division sign?

A fraction bar acts as an invisible pair of parentheses around the numerator and around the denominator. Written on one line, the fraction with numerator 3 + 5 and denominator 2 + 2 must be typed as (3 + 5) / (2 + 2) = 2. Typing 3 + 5 / 2 + 2 instead gives 7.5, because only the 5 gets divided.

What does the calculator do about division by zero?

It stops and explains that the expression asks for a division by zero, which has no value, rather than printing an infinity symbol. The same happens for a power with no real result, such as a negative base raised to a fractional exponent. Showing the reason is more useful than showing a misleading number.

Is this order of operations calculator free?

Yes. It is completely free, needs no sign-up, and there is no limit on how many expressions you can solve. Everything runs in your browser, so nothing you type is sent anywhere.

💡 Good to know

The order of operations is a convention, not a law of nature

Nothing in arithmetic forces multiplication to outrank addition. The convention exists because polynomials are written as sums of products, so giving products the higher tier removes thousands of brackets from ordinary algebra. Once you see that, the rule stops feeling arbitrary.

Your programming language agrees with your math teacher

Python, JavaScript, Java, C and SQL all use the same four tiers with the same left-to-right associativity, and all of them make exponentiation right associative where they have an operator for it. A correct PEMDAS answer is also the correct answer in code.

Not every expression is order sensitive

In the ten-row table above, three of the ten expressions give the same value read either way. The calculator shows both answers side by side so you can tell at a glance whether an expression is genuinely order sensitive or whether you were worrying about nothing.

Related Calculators