Turn precedence into a sequence
The order of operations calculator shows how one supported expression becomes a result. It exposes stage order rather than only drawing a parse tree. A reveal control can advance one reduction at a time, which makes each change easy to compare with the prior line.
The visible grammar has no exponents or functions. Its ordered levels are parentheses, postfix percent, unary negative, multiplication and division, then addition and subtraction. Multiplication and division share one precedence level and follow the parser’s left-associative tree. Addition and subtraction do the same.
Keep the original expression beside the trace whenever you share or revisit the calculation.
Read left associativity correctly
Equal precedence does not mean multiplication always precedes division or addition always precedes subtraction. For a left-associated chain, the operations bind according to the tree from left to right.
24 ÷ 6 × 2 becomes (24 ÷ 6) × 2 = 4 × 2 = 8, not 24 ÷ (6 × 2). Likewise, 10 − 3 + 2 becomes (10 − 3) + 2 = 9, not 10 − (3 + 2).
Parentheses can choose another grouping. The stage trace never commutes terms merely to make arithmetic easier, because doing so could obscure the source structure.
Worked example: a mixed chain
Enter 18 - 6 ÷ 3 × 2 + 1 with One reduction per row. There are no groups, percent tokens, or unary signs, so the first active level is multiplication and division.
Stage 1 reduces the leftmost division: 6 ÷ 3 = 2, leaving 18 - 2 × 2 + 1. Stage 2 reduces multiplication: 2 × 2 = 4, leaving 18 - 4 + 1. Stage 3 reduces the leftmost subtraction: 18 - 4 = 14, leaving 14 + 1. Stage 4 reduces addition to 15.
The final exact result is 15/1. Root operation is Add because the parsed top-level tree applies the last addition to the preceding subtraction chain. The ambiguity note explains that changing the expression to 18 - (6 ÷ 3 × 2 + 1) would produce a different tree.
One reduction versus a pass
One reduction per row replaces exactly one reducible node and is best for instruction or debugging. Same-precedence pass can display independent reductions at the same level together, but it must not combine operations whose inputs depend on an earlier reduction.
For the worked example, division and multiplication are dependent in the left-associated chain, so they remain separate even in pass mode. Inside (2 + 3) × (4 + 5), the two inner additions are independent and can appear in one parentheses pass before multiplication.
The stage count is based on actual node reductions, not the number of visual rows in pass mode. Copy trace preserves both values.
Parentheses and postfix percent
Deepest parentheses resolve before their surrounding operation. A group is not itself arithmetic; the nodes inside it are. After the inner value is known, the Group node can be replaced in the outer expression.
Percent applies to its immediate completed operand. 50 × (10 + 5)% resolves the group to 15, percent to 0.15, then multiplication to 7.5. The page never applies a contextual “percent of the left side” rule. Reject percent mode highlights the token instead.
Unary negative applies before multiplication at its source node. -3 × 2 therefore has a Negate stage over 3 followed by multiplication. The negative-number page provides a more intuitive sign-direction explanation for one operation.
Exact stage state and display
Every stage carries a reduced rational value. The text renderer may display a bounded decimal beside an exact fraction, but a rounded row never becomes the input to the next stage. This avoids compounding presentation rounding.
Expression-after-stage text is generated from the tree with enough parentheses to preserve meaning. It is not created by an unsafe string search and replace. Source positions remain available for errors before trace generation.
Each displayed reduction is reproducible from the preceding stage.
Common order mistakes this page cannot prevent
A perfect trace can still start from the wrong expression. Missing parentheses, a transcribed operator, or an inappropriate formula remain user responsibilities. The tool does not grade work, detect intent, accept implied multiplication, or decide which convention a course requires.
Some mnemonics make equal-precedence operations sound strictly ordered. Use the visible grammar and tree rather than relying on a letter sequence alone. If a context introduces powers, roots, functions, matrices, or units, this tool is incomplete.
Trace questions
Does multiplication always happen before division?
No. They share a precedence level; this parser preserves their left-associated source tree.
Can stages be revealed without recalculating?
Yes. The full deterministic trace is built locally, and the reveal cursor changes visibility only.
Does the tool support exponents?
No. It documents only the stated basic grammar.
Are hidden stages sent to a server?
No. Reveal state and all reductions remain in current page memory.
Enter a supported expression and select Build the precedence stage trace. Reveal one stage at a time, compare the operation and replacement, and use explicit parentheses if the source does not reflect the intended grouping.
