A free-form expression calculator with the four basic operations, parentheses, π, √, x², mod, percent — and a paper-tape history that lets you tap past calculations to bring them back.
This is a free-form expression calculator: you type an expression — by clicking the
keypad or by pressing keys on your physical keyboard — and the result appears as
you go. It supports the four basic arithmetic operations (addition, subtraction,
multiplication, division), parentheses, the square root function, the squaring
postfix x², the modulo operator, the constant π, percentages, and a paper-tape
history that remembers your recent calculations and lets you tap any past entry to
send it back to the editor.
The calculator follows the standard order of operations that you learned in
school: parentheses first, then exponents (here, x² and √), then multiplication,
division, and modulo (left to right), then addition and subtraction (left to
right). So 2 + 3 × 4 evaluates to 14, not 20, because multiplication binds
tighter than addition. If you want the addition to happen first, write
(2 + 3) × 4 and you get 20.
Implicit multiplication is supported between a number and an identifier or an
open parenthesis: 2π means 2 × π, (3+4)2 means (3+4) × 2, and 2(3+4)
means 2 × (3+4). This makes formulas read more naturally — you do not need to
type the × between consecutive factors.
Unary minus is handled wherever it is unambiguous: at the start of an
expression (-5), inside parentheses ((-3)), or right after a binary operator
(5 + -3). The display uses the proper minus sign character (−), not a
hyphen.
Pressing the √ key inserts √( into the expression — the opening parenthesis
is part of the insertion. You then type the expression you want the square root
of, and you can either close the parenthesis yourself or let the calculator do
it for you when you press =. The = key auto-balances any trailing
parentheses you forgot, so √9 is interpreted as √(9) and gives 3, while
√(2+3) gives the square root of 5.
The x² key squares whatever number or parenthesized group came right before
it. So 5x² is 25, (2+3)x² is 25, and 2+3x² is 11 because the squaring
binds tighter than the addition.
The π key inserts the constant π (approximately 3.141592653589793). Because
of implicit multiplication, expressions like 2π, π2, or (1+2)π all work
as you would expect — convenient when computing the area of a disk (π×r²),
the circumference of a circle (2πr), or any other geometric quantity.
The % key behaves contextually, like the percent key on most desktop and
phone calculators. When you write A + B%, the calculator interprets B% as
B percent of A and computes A + (A × B / 100) — so 200 + 10% is 220, not
200.1. The same rule applies to subtraction: 200 − 10% is 180. With
multiplication or division, B% simply means B / 100: 200 × 50% is 100. A
bare B% standing alone is also B / 100.
This contextual percent is the most common convention used in real calculators, and it is what most people mean when they tap the percent key after a price or a tax rate. If you want the literal divide-by-one-hundred behavior, just remove the surrounding operator.
The mod key inserts the modulo (remainder) operator. 17 mod 5 is 2, 100
mod 7 is 2, and so on. Modulo has the same precedence as multiplication and
division, so it binds tighter than addition and subtraction. It works on
non-integers too: 5.5 mod 2 is 1.5.
Above the keypad you see two display areas. The smaller one at the bottom of the display shows the current expression you are building. The larger one above it shows the live result of that expression as you type — green when the expression is valid and complete, blank when the expression is not yet a complete formula, red when something went wrong (a syntax error, a division by zero, a square root of a negative number, or an overflow).
Above both displays is the paper-tape area. Each time you press =, the
validated expression and its result are added as a new row at the bottom of
the tape. The tape scrolls if it gets long, and is preserved across page
reloads via your browser's local storage (the last fifty entries). Tap any row
in the tape to bring its expression back into the editor — handy for tweaking
a recent calculation without retyping it. The trash icon at the top right of
the tape clears it after a confirmation prompt.
The whole keypad is mirrored on your physical keyboard. Digits, the four
operators (+ - * /), parentheses, and the decimal mark (period or comma,
depending on your language) all map directly. Enter and = both validate.
Backspace deletes one character; Escape clears everything in the editor (a
long press on the on-screen ⌫ does the same). Letter shortcuts cover the
function keys: s inserts √(, ^ inserts x², m inserts mod, and
p inserts π. You can also paste in expressions from elsewhere — common
notations like sqrt(x), pi, x*y, and ^2 are normalized automatically.
This calculator is an everyday-arithmetic tool, not a scientific calculator:
there is no trigonometry, no logarithms, no exponentiation other than
squaring, and no memory registers (M+ M- MR MC). If you need any of those,
look for one of the dedicated calculators in the rest of the Calcorama
catalog, or wait for the upcoming scientific-calculator addition.