Most pocket calculators make you press equals repeatedly and lose the whole expression the moment you mistype a digit. This page takes the other approach: you type the entire expression as one line, exactly the way it would be written on paper, and it is evaluated in a single pass. That means you can see the whole calculation, change one term, and re-run it without starting over.
The evaluator is a hand-written recursive-descent parser rather than a call to JavaScript's own eval, which is what makes the accepted syntax predictable and the error messages specific.
The operator set is deliberately small:
| Symbol | Meaning |
|---|---|
+ − | addition, subtraction |
* or × or x or X | multiplication |
/ or ÷ | division |
^ | exponent, applied right to left |
% | postfix per cent, dividing by 100 |
( ) | grouping |
of | treated as multiplication |
Precedence runs the conventional way: parentheses first, then exponents, then multiplication and division, then addition and subtraction. Unary minus is handled as a sign attached to the value that follows.
Grouping and precedence. (12+8)*3^2 - 50/4 evaluates as 20 × 9 − 12.5 = 167.5. The parentheses are required: without them the expression would be a different sum entirely.
Per cent as a suffix. 20% of 250 becomes 0.2 × 250 = 50, because % divides the number in front of it by 100 and of is read as a multiplication. Writing 250*20% gives the same answer.
Right-associative powers. 2^3^2 is 2 raised to the 9th, or 512, not 8 squared. Stacked exponents group from the right, matching mathematical convention.
Sign before power. -2^2 returns −4, because the sign is applied to the completed power. Write (-2)^2 for positive four.
Binary noise is hidden by the output. 0.1+0.2 is not exactly 0.3 in binary floating point, but the result is displayed with at most ten decimal places, so the artefact never reaches the screen. It is still inside the value, which is why chaining many such additions can drift.
% is never modulo. It is per cent. 10%3 does not return 1; the three is left dangling after a per cent sign and the parser rejects the whole line. Use it for shares, never for remainders.2(3+4) is invalid; write 2*(3+4). Likewise 3x is not three times something.1,000+1 fails, because the comma splits one number into two values and the parser finds two numbers with no operator between them. Type 1000+1.2+abc3 quietly returns 5. If a result looks wrong, reread what you typed.2^0.5.Multiply by one plus the rate. A 15 per cent rise on 80 is 80*1.15. For a decrease, multiply by 0.85. Chaining several adjustments in one line works: 199*0.8*0.9.
Nearly always one of three things: an unmatched parenthesis, a number with a comma in it, or a per cent sign used as if it were a remainder operator. The parser reports an invalid expression rather than guessing at a repair.
The copy button puts the displayed value on your clipboard so it can be pasted into the next step. There is no chain of stored intermediate answers.
Up to ten, with trailing zeros removed. Whole results appear as whole numbers, so 6*7 shows 42 rather than 42.0000000000.
Related but narrower. The Percentage page asks and answers the three named percentage questions with labelled results; this page treats % as a plain divide-by-one-hundred instruction inside a longer expression. Use whichever matches the shape of the problem.