Order of Operations Calculator
An expression like 8 + 2 × 5 has one correct answer, yet people and cheap calculators often disagree about it. Some add first and get 50, while the agreed rules multiply first and give 18. Viral puzzles such as 6 ÷ 2(1 + 2) split the internet because the rules seem unclear. The real problem is usually that nobody shows the steps.
This order of operations calculator solves any arithmetic expression and rewrites it after every single operation. Each step is labeled with its rule, so you can see exactly where brackets, exponents, multiplication and addition take their turn. It handles parentheses, square brackets and braces nested in any order. You can label the steps with PEMDAS or BODMAS, whichever your school uses.
What Is the Order of Operations?
The order of operations is the agreed sequence for evaluating an expression with more than one operator. Grouping symbols come first, then exponents and roots, then multiplication and division, and finally addition and subtraction. Without this shared rule, the same line of numbers could produce several different answers. It is a convention rather than a law of nature, but every textbook and programming language relies on it.
Two details cause most confusion. Multiplication and division have equal rank, so they are done from left to right as they appear. Addition and subtraction also share a rank and follow the same left to right rule. The acronym PEMDAS lists M before D only because a word needs an order, not because multiplication wins.
How to Use the Order of Operations Calculator
Type or paste an expression such as 2 × [5 + (3 - 1)^2] and press Calculate. You can use the keypad or your keyboard, with * or × for multiplication and / or ÷ for division. Square brackets and braces work exactly like parentheses, as long as each one closes with its matching partner. Spaces are optional, so 2*(3+4) and 2 × (3 + 4) give the same result.
Show Steps displays the full expression after each operation, with the part that changed highlighted. Use the PEMDAS and BODMAS switch to label the steps in the style your class uses. The Implied multiplication first setting is off by default and changes how expressions like 2(3) behave next to a division. The final answer appears above the steps and can be copied with one click.
- Enter an expression with numbers, operators and any mix of brackets.
- Press Calculate or Enter to evaluate it.
- Turn on Show Steps to see the expression rewritten after each operation.
- Choose PEMDAS or BODMAS labels to match your textbook.
- Enable Implied multiplication first only if your course requires that convention.
- Copy the final answer with the copy button next to the result.
PEMDAS Step by Step: How Each Rule Works
The calculator always starts with the innermost group of brackets and works outward. Inside each group it applies exponents, then multiplication and division from left to right, then addition and subtraction from left to right. Once a group is reduced to a single number, its brackets disappear and the next level is solved. The final answer is what remains when no operators are left.
Two rules trip people up more than any others. Stacked exponents group from the right, so 2^3^2 means 2^(3^2), which is 512. A minus sign in front of a power is applied after the power, so -3^2 is -9 while (-3)^2 is 9. The steps panel names each of these rules, including the left-to-right associativity that breaks ties within a shared rank.
- P or B: solve parentheses, brackets and braces, innermost first.
- E or O: evaluate exponents and roots, grouping stacked powers from the right.
- M and D: multiply and divide from left to right.
- A and S: add and subtract from left to right.
- Repeat until one number is left.
Order of Operations Calculator Examples
These examples start with the classic traps and build up to nested brackets and real-world totals. Each one shows the input, the correct result and the rule that decides it. The later ones mirror homework problems and everyday bills.
Paste any of them into the tool above with Show Steps turned on. Comparing the rewritten lines with each explanation is the fastest way to lock the rules into memory.
Multiplication before addition
Enter 8 + 2 × 5 to get 18. The multiplication 2 × 5 happens first and gives 10, then 8 is added. Adding first would give 50, which is the most common wrong answer.
Brackets change everything
Enter (8 + 2) × 5 to get 50. The brackets force the addition first, so 10 is multiplied by 5. Compare this with the previous example to see how one pair of brackets changes the result.
Division and multiplication from left to right
Enter 20 ÷ 4 × 5 to get 25. Division comes first only because it appears first, giving 5, which is then multiplied by 5. Multiplying first would wrongly give 1.
Subtraction and addition from left to right
Enter 18 - 6 + 2 to get 14. Subtracting 6 from 18 leaves 12, and adding 2 gives 14. Adding first would give 10, a mistake that comes from reading PEMDAS too literally.
An exponent before addition
Enter 3 + 4^2 to get 19. The exponent turns 4^2 into 16 before anything is added. The steps panel labels this line with E in PEMDAS or O in BODMAS.
Stacked exponents
Enter 2^3^2 to get 512. Powers stack from the top down, so 3^2 = 9 is worked out first and then 2^9 = 512. Reading it from the left would give 64, which is how some spreadsheet software behaves.
A negative sign and a power
Enter -3^2 to get -9, then enter (-3)^2 to get 9. In the first case only 3 is squared and the minus applies afterward. Brackets are the only way to square the negative number itself.
The viral 6 ÷ 2(1 + 2) puzzle
Enter 6 ÷ 2(1 + 2) to get 9 with the default setting. After the brackets become 3, division and multiplication run left to right. So 6 ÷ 2 = 3, then 3 × 3 = 9. With Implied multiplication first turned on, the answer becomes 1 instead.
Nested brackets
Enter 2 × [5 + (3 - 1)^2] to get 18. The innermost group gives 2, which is squared to 4, then the square bracket becomes 9. Multiplying by 2 finishes the problem.
Braces around everything
Enter {4 + [12 ÷ (2 + 1)]} × 2 to get 16. The parentheses give 3, the square bracket gives 4 and the braces give 8. Each level closes before the next one opens up.
Typing a fraction correctly
A fraction with 10 + 6 on top and 2 × 4 below equals 2. Typed as (10 + 6) ÷ (2 × 4), the calculator agrees. Typed without brackets as 10 + 6 ÷ 2 × 4, it correctly returns 22, because the fraction bar was lost.
Averaging three test scores
Enter (90 + 80 + 70) ÷ 3 to get 80. Without brackets, 90 + 80 + 70 ÷ 3 divides only the last score and returns about 193.33. Averages always need brackets around the sum.
A food order total
Enter 3 × 12.50 + 2 × 4.75 + 5 to get 52. The two products, 37.5 and 9.5, are found first, and then the delivery fee of 5 is added. No brackets are needed because multiplication already outranks addition.
A negative inside brackets
Enter 10 - 2 × (3 - 5) to get 14. The brackets give -2, the multiplication gives -4, and subtracting -4 from 10 adds 4. Distributing the 2 but forgetting it on the 5 gives 10 - 6 + 5 = 9, a classic sign slip.
A discount before tax
Enter 50 × (1 - 0.2) × 1.08 to get 43.2. The bracket turns a 20% discount into a factor of 0.8, and 1.08 adds 8% tax. Multiplying the factors in any order gives the same total because only multiplication is involved.
A square root over a sum
Enter √(3^2 + 4^2) to get 5. The exponents give 9 and 16, the addition gives 25, and the root comes last because the bracket holds the sum. This is the Pythagorean distance for a 3 by 4 rectangle.
Operator Precedence in JavaScript, Python and Excel
Programming languages encode the order of operations as operator precedence and associativity. JavaScript and Python both group from the right, so 2 3 2 is 512 in each. They disagree on a leading minus: Python returns -4 for -2 2, while JavaScript refuses to run it at all. The language designers made that choice so nobody could misread the expression.
Spreadsheets add their own twist. In Microsoft Excel, =-2^2 returns 4 because negation is applied before the power. Excel also returns 64 for =2^3^2, because it reads exponents from the left. When results from code, a spreadsheet and a textbook disagree, add brackets until the intent is unambiguous.
// Exponents group from the right
console.log(2 ** 3 ** 2); // 512, read as 2 ** (3 ** 2)
console.log((2 ** 3) ** 2); // 64
// A leading minus before ** is a syntax error in JavaScript
// console.log(-2 ** 2); // SyntaxError
console.log((-2) ** 2); // 4
console.log(-(2 ** 2)); // -4print(2 ** 3 ** 2) # 512, exponents group from the right
print(-2 ** 2) # -4, the power is applied before the minus
print((-2) ** 2) # 4
print(20 / 4 * 5) # 25.0, division and multiplication run left to right
print(6 / 2 * (1 + 2)) # 9.0, no special rule for implied multiplicationExact Results and Privacy
Each step is computed with exact decimal arithmetic. A line like 0.1 + 0.2 shows 0.3, never a long tail of stray digits. Results that do not end, such as 10 ÷ 3, are rounded to 12 significant digits only when displayed. The unrounded value is carried into the next step, so rounding never compounds across a long expression.
Your expressions are evaluated inside your browser and are never uploaded, stored on a server or shared. The page does not need an account and works the same in every language version. It uses the same engine as the site's expression calculator, with extra support for square brackets, braces and labeled steps.
Common Order of Operations Mistakes
Most wrong answers come from treating PEMDAS as six separate ranks instead of four. The table below lists the mistakes teachers see most, along with the messages this tool shows for input it cannot read. Every fix can be checked by entering the expression above. Most of them disappear once you think in four ranks rather than six letters.
Bracket errors are the next most common problem, especially when square brackets and braces are mixed. Each opening symbol must close with the same kind of symbol, in reverse order. The tool points to the exact position of the first mismatch, so you can correct it quickly. More tools that follow the same rules are listed on the math calculators page.
Mistake or message | Example | Correct approach |
|---|---|---|
| Adding before multiplying | 8 + 2 × 5 read as 50 | Multiply first to get 18 |
| Always multiplying before dividing | 20 ÷ 4 × 5 read as 1 | Work left to right to get 25 |
| Always adding before subtracting | 18 - 6 + 2 read as 10 | Work left to right to get 14 |
| Squaring the minus sign | -3^2 read as 9 | The power comes first, so the answer is -9 |
| Losing a fraction bar | 10 + 6 ÷ 2 × 4 typed for a fraction | Put brackets around the top and the bottom |
| Missing closing parenthesis. | (2 + 3 × 4 | Add the bracket where the group ends |
| Mismatched brackets. | (2 + 3] × 4 | Close each bracket with the same type that opened it |
| Division by zero is undefined. | 8 ÷ (4 - 4) | Check the value inside the brackets |
PEMDAS vs BODMAS vs BIDMAS vs GEMDAS
The acronyms differ by country, but they describe the same rules and always produce the same answer. PEMDAS is common in the United States, BODMAS in India, Pakistan and much of Africa, and BIDMAS in the United Kingdom. GEMDAS replaces parentheses with grouping symbols to include brackets, braces and fraction bars. The middle letters change order in some versions, which is why the left to right rule matters.
Whichever acronym you learned, this order of operations calculator applies the same underlying ranks. Switching the label between PEMDAS and BODMAS changes only the names in the steps panel, never the result. Use the table below to translate between the systems. For trigonometry or logarithms inside an expression, switch to the scientific calculator.
Acronym | Stands for | Common in | Same result? |
|---|---|---|---|
| PEMDAS | Parentheses, Exponents, Multiplication and Division, Addition and Subtraction | United States | Yes |
| BODMAS | Brackets, Orders, Division and Multiplication, Addition and Subtraction | India, Pakistan, Nigeria, Australia | Yes |
| BIDMAS | Brackets, Indices, Division and Multiplication, Addition and Subtraction | United Kingdom | Yes |
| GEMDAS | Grouping symbols, Exponents, Multiplication and Division, Addition and Subtraction | Some US and Philippine classrooms | Yes |
| Programming precedence | Operator precedence plus associativity rules | JavaScript, Python, Excel | Mostly, except negatives and stacked powers |
| MDAS | Multiplication and Division, Addition and Subtraction | Philippines | Yes |
Order of Operations Questions Answered
These answers cover the questions people search most about PEMDAS, BODMAS and calculators. Several come from debates that start with a single viral puzzle. They run from the basic rules to the edge cases.
Each answer is short, and the examples above show the same rules in full. Try any expression in the tool to confirm the result for yourself.