Scientific Calculator

A full scientific calculator with trigonometry, logarithms, powers, roots, factorials and constants — parsed with a hand-written tokeniser and shunting-yard algorithm, never with eval.

Updated August 2026 Math & Statistics

Write an expression

Angle mode
Result
To 4 significant figures
Scientific notation
Reciprocal
Squared

About precision. Results are computed in double-precision floating point, which is exact for whole numbers up to about sixteen digits and very slightly approximate beyond that. Figures are rounded for display, so a long chain of calculations can differ from a hand-worked answer in the last decimal place. Where an exact fraction or radical exists, this page shows it alongside the decimal.

How to Use the Scientific Calculator

This is a full expression calculator rather than a button-at-a-time one: you write the whole calculation and it is parsed as a unit, so operator precedence and brackets behave the way they do on paper. Nothing you type is ever executed as code.

  1. Type an expression into the field, or build one with the keypad. Both do the same thing — the keypad simply inserts text at the cursor.
  2. Use brackets freely. Multiplication and division bind more tightly than addition and subtraction, and powers bind more tightly still, so 2 + 3 × 4 is 14 rather than 20. Brackets override that when you need them to.
  3. Set the angle mode before using any trigonometry. Degrees is the default because it is what most people expect; radians is what mathematics uses and what every other calculator on this site assumes.
  4. Functions take brackets: sin(30), ln(7), sqrt(1728). Available are sin, cos, tan and their inverses, the hyperbolic versions, ln, log, sqrt, cbrt, abs, exp, floor, ceil, round and sign.
  5. Constants are words: pi, e, tau and phi. A factorial is a trailing exclamation mark, so 5! is 120, and the percent sign is a remainder operator rather than a percentage.

Errors are reported in plain language and point at the character that caused them. An unclosed bracket says so; an unknown function name is quoted back to you.

How the Expression Is Parsed

The parser is worth describing, because how a calculator reads an expression determines what it answers.

1. Tokenise — split the text into numbers, operators, functions and brackets2. Shunting-yard — reorder into Reverse Polish Notation by precedence3. Evaluate — run the RPN on a stack, one token at a timePrecedence: ^ then unary minus then × ÷ mod then + −Powers are right-associative: 2^3^2 is 2^(3^2) = 512, not (2^3)^2 = 64No part of this uses eval(), new Function() or any other route from text to executable code. An expression is data from the first character to the last, which is the only safe way to accept arbitrary input.
What each symbol means
SymbolMeaningUnitTypical range
TokensNumbers, operators, functions, brackets
PrecedenceWhich operator binds more tightlylevel1 – 4
RPNReverse Polish Notation, an operator stack order
Angle modeDegrees or radians for trigonometry
LengthMaximum expression lengthcharacters400

The shunting-yard algorithm was published by Edsger Dijkstra in 1961 and is still the standard way to turn infix notation into something a machine can evaluate. It reads left to right once, pushing operators onto a stack and popping them when a lower-precedence one arrives — which is why it needs no backtracking and runs in linear time.

Example

How 2 + 3 × 4 is read

  1. Tokenise: 2, +, 3, ×, 4.
  2. Push 2 to the output. Push + to the operator stack.
  3. Push 3 to the output. The next operator, ×, binds more tightly than +, so + stays on the stack.
  4. Push 4 to the output, then pop the stack. The output is 2 3 4 × + in Reverse Polish Notation.
  5. Evaluate on a stack: 3 × 4 = 12, then 2 + 12 = 14.
  6. With brackets, (2 + 3) × 4 becomes 2 3 + 4 × and evaluates to 20.

The default expression

sqrt(1728) + 5! tokenises into a function, a number, an operator and a factorial. The square root of 1,728 is 41.5692193817 and 5! is 120, so the result is 161.5692193817. Try replacing the factorial with 5!! and the parser will tell you a factorial sign has no number in front of it, rather than producing something arbitrary.

Two results that surprise people

First, 2^3^2 = 512. Powers associate to the right, so it means 2^(3^2) = 2^9, not (2^3)^2 = 64. Second, −3^2 = −9. The power binds more tightly than the minus sign, so it is −(3^2) rather than (−3)^2. Both follow the standard mathematical conventions, and both differ from what some spreadsheet software does — which is worth knowing before trusting either.

Precedence, Angle Mode and Floating Point

Every operator and function, in precedence order.

What binds most tightly, and what each symbol does
LevelSymbolsAssociativityNote
4 — highest^Right2^3^2 is 2^(3^2) = 512
3Unary minusRightBinds looser than a power, so −3^2 = −9
2× ÷ modLeftmod is the remainder, not a percentage
1 — lowest+ −LeftEvaluated last unless brackets say otherwise
Functionssin cos tan ln log sqrt …Always take brackets

The one entry worth reading twice is unary minus. Placing it below the power operator is the standard mathematical convention and it means −3² is negative nine, because the squaring happens first. If you want the square of negative three, write (−3)^2 and the brackets settle it.

The angle mode catches people more often than anything else on the page. In degrees, sin(30) is exactly 0.5. In radians, sin(30) is −0.988, because thirty radians is about 1,719 degrees and lands somewhere quite different on the circle. Neither answer is wrong; they answer different questions, and the toggle is above the field for that reason.

Everything is computed in double-precision floating point, which is exact for whole numbers up to about sixteen digits. Beyond that, and for any decimal that cannot be written exactly in binary, results are very slightly approximate — which is why 0.1 + 0.2 comes to 0.30000000000000004 in almost every programming language, including the one this page is written in. The display rounds to ten decimal places, which hides that particular artefact without pretending it is not there.

Four Things This Calculator Does Not Do

Four things this calculator deliberately does not do.

It does not use eval. The obvious way to build an expression calculator in a browser is to hand the text straight to the language's own evaluator. It is also the way to let any string that reaches the field run as code. Writing a parser is more work and it means an expression is never anything but data.

It does not do symbolic algebra. There are no variables, no solving for x and no simplification of expressions. Every input evaluates to a single number, which is a deliberate limit rather than an omission.

It does not handle complex numbers. The square root of a negative number returns an error rather than an imaginary result, and an even root of a negative does the same. Anything requiring the complex plane needs a different tool.

It does not keep arbitrary precision. Factorials above 170 overflow and are refused rather than silently returning infinity. Very large integers lose exactness past sixteen digits, which is a property of the number format rather than of the parser.

One design decision worth explaining. The keypad inserts text at the cursor rather than driving a hidden state machine, which means you can freely mix typing and tapping, edit the middle of an expression, and see exactly what will be evaluated before it is. Traditional calculators hide their working in an internal register and that is where most user errors come from — a pending operation you have forgotten about, silently applied when you press equals.

Here the expression is the whole state. If it looks right, it is right, and if it is wrong you can see the wrong part and fix it rather than starting again.

Within those limits it is a complete scientific calculator, and the specialised pages elsewhere on the site do the same arithmetic with explanation attached — the exponent calculator for powers, the square root calculator for roots and radical form, and the standard deviation calculator for anything involving a dataset rather than a single expression.

Frequently Asked Questions

It tokenises the text, reorders it into Reverse Polish Notation with the shunting-yard algorithm, then evaluates it on a stack. Nothing is passed to eval or any other code-execution route.

Because multiplication binds more tightly than addition, so the multiplication happens first. Writing (2 + 3) × 4 gives 20 instead.

Powers associate to the right, so it means 2^(3^2) = 2^9 = 512. Reading it left to right as (2^3)^2 would give 64, which is not the mathematical convention.

The power binds more tightly than the minus sign, so it is −(3²) = −9. For the square of negative three, write (−3)^2 and the brackets settle it.

In degrees sin(30) is exactly 0.5; in radians it is −0.988, because thirty radians is about 1,719 degrees. Set the toggle before doing any trigonometry.

sin, cos, tan, their inverses, the hyperbolic versions, ln, log, sqrt, cbrt, abs, exp, floor, ceil, round and sign. Constants are pi, e, tau and phi.

A trailing exclamation mark: 5! is 120. It needs a whole number of zero or more, and anything above 170 is refused because the result cannot be represented.

It is a remainder operator, not a percentage. 10 % 3 gives 1. For percentage work, the percentage calculator is the right tool.

No. It returns an error rather than an imaginary result, because complex numbers are outside what this calculator covers.

Because binary floating point cannot represent those decimals exactly. The true result is 0.30000000000000004, which the display rounds away — an artefact of the number format rather than of the parser.