Order of operations is the agreed-upon rule that makes a written expression like 3 + 4 ร— 2 mean exactly one thing instead of several. This calculator evaluates any expression you type using a safe, hand-written parser โ€” never a string-execution shortcut โ€” and narrates the reduction step by step so you can see exactly which rule fired at each stage.

How the calculator works

The calculator reads your expression into a small parse tree that already encodes precedence: exponents nest inside multiplication/division, which nest inside addition/subtraction, and parenthesized groups nest wherever you placed them. It then reduces that tree in four passes โ€” parentheses first (recursively, innermost group first), then exponents, then multiplication and division left to right, then addition and subtraction left to right โ€” recording one step every time a single operation is resolved. No eval() or dynamic code execution is used anywhere; every step is a real arithmetic operation you can verify by hand.

Reading the input

Type numbers, +, - (or the โˆ’ sign), * or ร— for multiplication, / or รท for division, ^ for exponents, and parentheses for grouping. Decimals are supported (2.5 ร— 4), as is a leading minus sign for negative numbers (-3 + 4), and writing a number or a closing parenthesis directly before an opening parenthesis is read as implicit multiplication (2(3 + 4) means 2 ร— (3 + 4)). A stacked exponent like 2^3^2 evaluates right to left, matching the standard convention, and a leading minus binds looser than an exponent, so -2^2 equals โˆ’4, not 4 โ€” write (-2)^2 if you want the negative squared.

Limits and edge cases

The parser rejects anything that isn't a number, an arithmetic operator, or a parenthesis โ€” there are no variables, functions, or unit conversions here, and dividing by zero or leaving parentheses unbalanced returns a clear error message instead of a wrong answer. Very long expressions (over 500 characters) are also rejected as a sanity limit. For scientific functions like sine, logarithms, or factorials, use the site's Scientific Calculator instead; this tool is purpose-built for demonstrating and checking plain PEMDAS/BODMAS arithmetic.