Calculator — expressions with brackets, powers, roots and percent
Type a whole expression and get the answer: brackets, × ÷, powers, square roots, logs, trig functions and percent signs (so 120 + 15% really gives 138). Use your keyboard or the on-screen keys. Parsing and maths happen on your device.
Press Enter for the answer — brackets and minus work straight from the keyboard.
Worked expressions
| Type | Result | Scientific notation | Rule it follows |
|---|---|---|---|
| 120+15% | 138 | 1.38 × 10^2 | the percent applies to the number before + |
| 2^10 | 1,024 | 1.024 × 10^3 | ^ is power, output groups thousands |
| sqrt(3^2+4^2) | 5 | 5 × 10^0 | a function takes the bracket after it |
| 2 3 | 6 | 6 × 10^0 | a space between numbers means × |
| 0.1+0.2 | 0.3 | 3 × 10^−1 | float noise trimmed to 12 digits |
Grammar, radians, precision
What you can write
| Kind | Syntax | Notes |
|---|---|---|
| Arithmetic and brackets | + - * / ( ), × ÷ also accepted |
Normal precedence, brackets nest freely |
| Powers and roots | 2^10, sqrt(2), cbrt(27) |
^ is right-associative, so 2^3^2 is 2^9 |
| Percent | 50%, 120+15% |
Two meanings — see below |
| Functions | abs floor ceil round ln log10 log2 exp sin cos tan asin acos atan |
log10( is read as one name |
| Constants | pi, e |
2pi works too; the multiplication sign is implied |
| Scientific input | 1.5e3, 2e-4 |
Same as 1500 and 0.0002 |
| Thousands separators | 1,000+1 |
A comma counts as a grouping mark only when exactly three digits follow it; 3,4 is an error rather than a silent 34 |
| Spaces | 1 + 2 3 |
A space is an operand boundary, so 2 3 means 2×3 and the answer is 7 — never a glued-together 23 |
Percent does two different jobs
50% alone means 50 ÷ 100 = 0.5. But a percent sign sitting right after + or - is taken of the value on its left, which is what pocket and phone calculators do:
120+15%→ 120 + 120×15% = 138 (a 15% increase)120-15%→ 102 (15% off)120+15%+10%→ the running total 138 grows by 10% → 151.8 (successive increases compound)120*15%→ 120 × 0.15 = 18 — here the percent falls back to its plain meaning
When you want no ambiguity at all, write 120*1.15. It reads better too.
Trig uses radians
sin(pi/2) = 1. For degrees, convert yourself: sin(45*pi/180). There is deliberately no degree switch — mixing two units inside one line is how silent errors get made.
Precision
Results show 12 significant digits. That rounding exists to remove artefacts like 0.1+0.2 giving 0.30000000000000004; it is not a quirk of this implementation but the nature of IEEE 754 double-precision numbers, which every mainstream language shares.
Therefore:
- Exact decimal money arithmetic belongs in a decimal library or a spreadsheet, not here;
- Scientific work needing 15+ significant digits gets trimmed to 12;
- Overflow such as
10^400reports “out of range” instead of printingInfinity.
Where your input goes
There is no eval in the parser. The expression is tokenised by the grammar above, built into a parse tree by recursive descent, then evaluated — all in your browser, and your expression never goes into a request body. What you type never leaves this device.