Exact arithmetic on rationals, with both evaluation conventions named and the precedence table the parser runs on printed on the page.
Initializing in your browser…
Add, subtract, multiply, divide, compare and simplify fractions of any size, exactly. Reads mixed numbers and repeating decimals, and gives the decimal expansion with its repeating cycle.
Aspect ratios reduced exactly by the greatest common divisor, with the reduction multiplied back as a check, resizes that say whether they are exact, and named ratios that carry a note where the name is not the ratio.
Exact ages and date differences worked out on the calendar itself, with no arithmetic on milliseconds, so the answer is the same in every time zone. Shows which days are not 86,400 seconds long.
You press 2 + 3 × 4 = and want to know why two calculators give you two different answers.
Keys
2 + 3 × 4 =
Both answers
Algebraic (precedence): 14 Chain (desk calculator): 20 2 → 5 → 20, because × applies the pending +
A four-function calculator applies whatever operation is pending the moment you press the next operator key, so it computes 2 + 3 = 5 and then 5 × 4 = 20. Algebraic notation waits, because × binds more tightly than +. Neither is a bug; the fault is not saying which. This page implements both, names them, and prints the precedence table its parser actually runs on.
A scientific calculator that says which evaluation convention it is using, and computes exactly wherever exact arithmetic exists. 2 + 3 x 4 is 14 under operator precedence and 20 on a four-function desk calculator, and both are right for what they are; this one lets you pick and prints the precedence table it runs on.
Two faults sit in almost every calculator on the web, and both were in this one. The first is that a chain calculator applies the pending operation the moment you press the next operator, so 2 + 3 x 4 comes out as 20 and 1 + 2 ^ 3 as 27. That is not a bug in a desk calculator, it is what one does, and anybody who has used one relies on it. It is wrong for something labelled scientific, and the shipped version did it with nothing on the page saying which convention was in force. Here both are implemented, both are named, and switching between them on the same expression shows the difference. The precedence and associativity table is a value in the source that the parser climbs, so it cannot drift from what the calculator actually does, and it is printed on the page with the places conventions genuinely differ marked (the power is right associative and binds tighter than a unary minus, so 2^3^2 is 512 and -2^2 is -4). The second fault is the raw double: 0.1 + 0.2 showed as 0.30000000000000004 and every factorial from 23! up was approximate with nothing saying so. Here every operation that can be exact is done on rational numbers over arbitrary-precision integers, so 0.1 + 0.2 is exactly 0.3, 1/3 is a third rather than 0.333333, and 100! is all 158 digits. Where a value genuinely is irrational the answer falls back to the nearest double and the page says which operation made it inexact.
Percentages, powers and roots with the answer exact rather than the nearest double to it.
Spreadsheets differ on whether the power is right associative and on how a unary minus binds; the table here says what this calculator does.
nCr, nPr and factorials of any size, computed on big integers so every digit is there.
Running the same keys under both conventions makes visible why the desk calculator on your phone and the one in a programming language disagree.
A third stays a third through the whole calculation, and the answer is shown as a fraction and as a repeating decimal.
Because there are two conventions. Algebraic notation gives multiplication a higher precedence than addition, so it is 14. A four-function desk calculator applies the pending operation as soon as you press the next operator key, so it computes 2 + 3 first and gets 20. Both are used by real machines; this page names which one is in force.
Because the power operator is right associative, so it means 2^(3^2). That is the convention in mathematics, Python and every computer algebra system. Some spreadsheets group it the other way, which is one of the reasons the precedence table is on the page.
Because the power binds more tightly than a unary minus, so it reads as -(2^2) = -4. If you want (-2)^2 = 4, put the brackets in.
Because the arithmetic is done on rational numbers over arbitrary-precision integers rather than on floating-point doubles. The answer says whether it is exact, and where a value really is irrational (a logarithm, a sine, pi) it says so and falls back to a double.
Because e is a constant on this calculator, and one string cannot mean both a thousand and the exponent of Euler's number. It is refused by name rather than guessed at. Write 1000 or 1 * 10^3.
It divides by a hundred, so 50% is 0.5, which is what a desk calculator's % key does. The remainder is written mod, because a % b for a remainder and a% for a percentage cannot both be true. The remainder uses truncated division, so -7 mod 3 is -1; Python gives 2 because it floors instead.
20000!, and every digit is real, because the arithmetic is on big integers. A double loses precision from 23! onwards and overflows completely at 171!.
Every calculation runs locally in your browser. Your numbers and expressions are not transmitted or stored.