What is this calculator?
This is an expression calculator: instead of pressing buttons one number at a time, you type the whole calculation, such as 12 * (3 + 4), and it works out the answer in one go. It follows the standard order of operations, so you can write a sum the way it appears on paper without breaking it into steps.
How to use it
- Type an expression into the box. Spaces are optional, so
12*(3+4)and12 * (3 + 4)are the same. - Click Calculate.
- Read the result. If something in the expression can't be understood, an error message tells you what went wrong.
Order of operations
When an expression mixes operators, the calculator applies them in this order. Operators on the same row are worked left to right, except powers, which work right to left.
| Priority | Operator | Typed as | Example | Result |
|---|---|---|---|---|
| 1 | Brackets | ( ) |
(4 + 6) * 3 |
30 |
| 2 | Powers | ^ |
2^3^2 |
512 |
| 3 | Negative sign | - |
-2^2 |
-4 |
| 4 | Multiply, divide | * / |
100 - 15 / 3 * 2 |
90 |
| 5 | Add, subtract | + - |
2 + 3 * 4 |
14 |
Two of these catch people out:
- Stacked powers work from the right.
2^3^2is 2^(3^2) = 2^9 = 512, not (2^3)^2 = 64. - A leading minus sign comes after the power.
-2^2is -(2^2) = -4. Put the negative number in brackets,(-2)^2, to get 4.
The famous viral sum 8 / 2 * (2 + 2) gives 16 here. After the brackets, division and multiplication have equal priority and go left to right: 8 / 2 = 4, then 4 * 4 = 16.
Worked example
Take (4 + 6) * 3 / 5 - 2^3:
- Brackets: 4 + 6 = 10, leaving
10 * 3 / 5 - 2^3. - Powers: 2^3 = 8, leaving
10 * 3 / 5 - 8. - Multiply and divide, left to right: 10 * 3 = 30, then 30 / 5 = 6, leaving
6 - 8. - Subtract: 6 - 8 = -2.
What it doesn't accept
The parser is strict about notation, so some things that look normal on paper produce an error:
| You typed | What happens | Type this instead |
|---|---|---|
2(3) |
Unexpected token '(' | 2 * 3 (multiplication must be written) |
50% |
Character could not be parsed | 50 / 100 or 0.5 |
1,000 + 1 |
Character could not be parsed | 1000 + 1 |
1e3 |
Unexpected token 'e' | 1000 or 10^3 |
5 / 0 |
Division by zero | — |
sqrt(4) |
Unknown identifier 'sqrt' | Use the scientific calculator |
Rounding and limits
Numbers are stored as 64-bit floating-point values, the same format most programming languages use. Most decimals can't be stored exactly in binary, which is why 0.1 + 0.2 is really 0.30000000000000004 inside a computer (the Python documentation has a clear explanation). This calculator rounds the result to 10 decimal places before showing it, which hides that noise: you see 0.3.
The rounding has two side effects worth knowing:
- Very small results, below 0.00000000005, display as 0.
- Results too big for a 64-bit number, such as
10^400, display as inf, and impossible ones such as(-8)^(1/3)display as nan (not a number). Treat either as "no valid answer".
Fractional powers work for positive numbers: 2^0.5 is the square root of 2, 1.4142135624.
When to use a different calculator
This page handles arithmetic. For square roots, logarithms and trigonometry, switch to the scientific calculator, which uses the same syntax. If you want an exact answer like 5/6 rather than 0.8333333333, use the fraction calculator. The percentage calculator covers percent change and "X is what percent of Y" without any typing of formulas.
Last updated