Skip to content
AgileLogics

Basic Calculator

Evaluates an arithmetic expression using standard operator precedence: +, −, ×, ÷, powers (^), and parentheses.

How it works

Enter an expression, e.g. 12 * (3 + 4).

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

  1. Type an expression into the box. Spaces are optional, so 12*(3+4) and 12 * (3 + 4) are the same.
  2. Click Calculate.
  3. 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^2 is 2^(3^2) = 2^9 = 512, not (2^3)^2 = 64.
  • A leading minus sign comes after the power. -2^2 is -(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:

  1. Brackets: 4 + 6 = 10, leaving 10 * 3 / 5 - 2^3.
  2. Powers: 2^3 = 8, leaving 10 * 3 / 5 - 8.
  3. Multiply and divide, left to right: 10 * 3 = 30, then 30 / 5 = 6, leaving 6 - 8.
  4. 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

Frequently asked questions

Which symbols can I type?
Use + and - for addition and subtraction, * for multiply, / for divide, ^ for powers, and round brackets for grouping. Decimals use a point (2.5). The constants pi and e are also recognised. Symbols such as ×, ÷, % and thousands commas aren't accepted.
In what order does it calculate?
Brackets first, then powers, then multiplication and division from left to right, then addition and subtraction from left to right. So 2 + 3 * 4 is 14, and 8 / 2 * (2 + 2) is 16.
What is -2^2?
The calculator gives -4. The power is applied before the minus sign, which matches the usual mathematical convention. Type (-2)^2 if you want 4.
How do I work out a percentage?
The % sign isn't supported, so write the percentage as a decimal. 15% of 1,250 is 1250 * 0.15, which gives 187.5. The percentage calculator handles percent change and "what percent of" questions directly.
How many decimal places does it show?
Up to 10, with trailing zeros removed. 10 / 3 shows as 3.3333333333 and 0.1 + 0.2 shows as 0.3. Anything smaller than 0.00000000005 rounds to 0.
What happens if I divide by zero?
You get the message "Division by zero." instead of a result. A missing bracket or an unknown symbol also shows an error explaining what couldn't be read.