How a pocket calculator works
Press 7, then ×, then 8. A machine costing less than a sandwich answers instantly and has never once been wrong. It manages this without a multiplication circuit, without understanding decimals, and — in the case of the solar panel on the front — without much help from the light falling on it.
How it knows which key you pressed
A calculator has around 25 keys. Wiring each one to its own pin on the chip would need 25 pins just for the keypad, on a chip that might only have 40 in total. Nobody does this, and the trick that avoids it is used in every keyboard you have ever typed on.
The keys are arranged in a grid of rows and columns. Each key sits at an intersection, and pressing it connects that row to that column — nothing more. A five-by-five grid handles 25 keys using ten pins instead of 25.
Bounce, and why it has to be ignored
A mechanical switch does not close cleanly. The contacts strike, separate, and strike again several times over a few milliseconds before settling. A chip scanning hundreds of times a second sees this as one press, then a release, then another press — and you would get 777 for one tap of the 7 key.
The fix, called debouncing, is to require the same reading several scans in a row before believing it, or to ignore any further change for a few milliseconds after one. It is a couple of lines of logic and it is the difference between a calculator that works and one that is useless.
Ghosting, and the diodes that are usually missing
A matrix has one genuine flaw. Hold down three keys that form three corners of a rectangle in the grid, and current can flow around the edges in a way that makes the chip see a fourth key at the remaining corner. This is ghosting.
Proper keyboards prevent it with a diode at every key, forcing current one way. A calculator does not bother, because nobody presses three keys at once on a calculator, and 25 diodes cost more than the problem. Cheap membrane keyboards make the same trade, which is why some games cannot register certain key combinations.
The takeaway Keys are read as a grid, not individually. The chip lights up one row at a time and sees which column answers, hundreds of times a second, and throws away the mechanical noise of the switch closing.
It counts in decimal, using binary
A computer stores 25 as 11001 — binary, efficient, and awkward to display. A calculator usually does something different and slightly wasteful, for a reason that matters more than the waste.
In binary-coded decimal, each decimal digit gets its own group of four bits. The number 25 is stored not as 11001 but as 0010 0101 — a 2 and a 5, kept separate. Four bits can represent 0 to 15, so six of the sixteen possible patterns are simply never used.
Why waste the space
Because the calculator's entire job is to display decimal digits to a human, and BCD means no conversion is ever required. Digit three of the answer is already sitting in its own four bits, ready to be sent to the display. Converting pure binary to decimal needs repeated division, which is expensive in hardware and would have to happen on every single update.
The second reason matters more. Ordinary binary floating point cannot represent 0.1 exactly — in binary it is a recurring fraction, just as a third is in decimal. Add 0.1 to 0.2 in most programming languages and you get 0.30000000000000004. A calculator that did that would be returned to the shop.
The cost: correcting after every addition
Adding BCD digits needs a fix-up. Add 7 and 5 in four-bit binary and you get 1100, which is 12 — a perfectly good binary answer and a meaningless BCD digit. The hardware notices the result exceeded 9, adds 6 to push it past the unused patterns, and carries into the next digit, leaving 0001 0010: one and two. Every processor of that era had an instruction for exactly this correction.
The takeaway Each decimal digit gets its own four bits. It wastes space and needs a correction after every sum, and in exchange the machine never produces a rounding error a human would notice.
Addition, built from two logic gates
Underneath the digits, the only thing the chip can really do is combine electrical signals according to fixed rules. Remarkably, that is enough — addition falls out of two simple gates, and everything else is built on top of addition.
Start with one bit plus one bit. There are only four possible cases, and writing them out reveals the whole design.
| A | B | Sum bit | Carry out |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
The sum column is 1 when exactly one input is 1 — that is an XOR gate. The carry column is 1 only when both inputs are 1 — that is an AND gate. Two gates, and you can add two bits. This is called a half adder.
To chain them you need to accept a carry coming in from the digit to the right as well, which takes two half adders and an OR gate. That is a full adder, and wiring a row of them together — each one's carry out feeding the next one's carry in — gives you a circuit that adds numbers of any width.
Subtraction is addition in disguise
There is no subtraction circuit. To compute A − B, the hardware flips every bit of B, adds 1, and then adds the result to A. That operation — invert and increment — produces the two's complement, a representation of the negative number that makes ordinary addition produce the right answer. One adder does both jobs, which halves the silicon.
Multiplication is addition and shifting
There is usually no multiplication circuit either. Multiplying by two in binary is just shifting every bit one place left, exactly as multiplying by ten in decimal appends a zero. So 13 × 5 becomes: take 13, note that 5 is 101 in binary, and add together 13 shifted by two places and 13 shifted by none.
Division is the same idea run backwards: repeated subtraction and shifting. Both take several clock cycles rather than one, which is why on a very cheap calculator a long division can take a perceptible instant while addition never does.
The takeaway An XOR gate and an AND gate add two bits. A row of those adds whole numbers. Subtraction, multiplication and division are all rearrangements of that one circuit plus shifting.
How it computes a sine with no multiplier
Addition and shifting explain arithmetic. They do not obviously explain how a 1970s calculator with no multiplier and a few hundred bytes of ROM produced sin, cos, tan, log and square roots to ten digits. The answer is one of the most elegant algorithms in computing.
The algorithm is CORDIC — COordinate Rotation DIgital Computer — published in 1959 for aircraft navigation and adopted by essentially every calculator and early coprocessor since.
The idea: rotate a vector until it lands where you want
To find the sine of an angle, imagine an arrow of length 1 pointing along the x axis. Rotate it by that angle, and the height of its tip is the sine while its horizontal distance is the cosine. The problem is that rotating by an arbitrary angle normally needs multiplication by sine and cosine — the very things you are trying to find.
CORDIC's insight is to rotate by a fixed sequence of ever-smaller angles, chosen so each rotation needs only a shift and an add. You overshoot, come back, overshoot by less, and after enough steps you have converged on the angle you wanted.
The same machinery does almost everything
What makes CORDIC so valuable is that small variations of the same loop produce a whole library of functions. Run it in 'rotation mode' and you get sine and cosine. Run it in 'vectoring mode' and you get arctangent and the magnitude of a vector. Swap the circular rotations for hyperbolic ones and the same structure yields exponentials, natural logarithms and square roots.
| Function | How CORDIC produces it |
|---|---|
| sin, cos | Circular rotation mode |
| arctan, √(x²+y²) | Circular vectoring mode |
| sinh, cosh, eˣ | Hyperbolic rotation mode |
| ln, √x | Hyperbolic vectoring mode |
| tan | sin ÷ cos, using the divider |
| log₁₀ | ln x multiplied by a stored constant |
One small loop, a table of forty constants and a few mode flags replace what would otherwise be an enormous amount of dedicated circuitry. It is the reason a scientific calculator was possible at all in an era when a multiplier was an expensive luxury.
CORDIC has never gone away. It is still used in FPGAs, in signal processing hardware and anywhere a multiplier is scarcer than time — which, once again, describes a great deal of modern low-power electronics.
The takeaway Trigonometry is done by rotating a vector through a fixed series of ever-smaller angles, each chosen so the rotation is a shift and an add. Forty constants replace every transcendental function.
Turning the answer into visible digits
The answer exists as groups of four bits. Getting it onto the glass involves a small piece of logic that has not changed in fifty years, and a display technology that does not emit any light at all.
Seven segments, and the decoder that drives them
Each digit position is seven bars arranged in a figure eight, labelled a to g. Every decimal digit is a different combination of them. A seven-segment decoder takes the four bits of a BCD digit and turns them into seven on-off signals — a fixed piece of logic with four inputs and seven outputs.
An LCD does not produce light
This is the part that surprises people. A liquid crystal display emits nothing. Every photon reaching your eye from a calculator screen arrived from the room and bounced off a mirror at the back. The display's only job is to stop some of that light from getting out, which is why a calculator is unreadable in the dark and perfectly clear in bright sunshine — the exact opposite of a phone.
- Light enters through a polarising filter, which only lets through waves vibrating in one direction.
- It passes through a layer of liquid crystal — a substance whose molecules form an ordered twist, rotating the light's polarisation by 90 degrees as it travels.
- It meets a second polariser turned 90 degrees to the first. Because the crystal twisted the light to match, it passes through, hits the mirror and comes back out. The segment looks clear.
- Apply a voltage across one segment and the molecules there straighten up, so the twist disappears. That light arrives at the second polariser still in its original orientation and is blocked.
- Blocked light means no reflection, so that segment appears black against the grey. The digit is drawn in the absence of light, not its presence.
Because nothing is being illuminated, the power required is almost nothing — the voltage only has to twist molecules, not produce photons. A segment draws microwatts. This is the single biggest reason a calculator battery lasts years while a phone lasts a day.
The voltage has to alternate
One detail that matters: the voltage across a segment is constantly reversed, hundreds of times a second. A steady DC voltage would cause ions to migrate through the liquid crystal and permanently damage it within weeks. Alternating the polarity produces the same twisting effect with no net current flow. A display showing permanently dark patches or ghostly shadows has usually suffered exactly this.
The takeaway Four bits become seven segment signals through fixed logic. The display then draws digits by blocking ambient light rather than emitting any, which is why it costs almost no power and needs a lamp to read.
The solar cell that is barely doing anything
Cover the little black strip on a solar calculator and it keeps working. Cover it in a dark cupboard for a year and it still works. The panel is real, it does generate electricity, and it is not what is running your calculator.
Almost every 'solar' calculator is a hybrid. There is a small photovoltaic strip and, behind the case, a button cell — often a lithium coin cell or, on older models, a battery soldered in place and never intended to be replaced. The two are wired so that the cell supplies whatever the panel cannot, which under normal indoor lighting is most of it.
The numbers involved are tiny
A basic calculator running its display and scanning its keypad consumes in the region of ten microwatts. That is roughly a hundred-thousandth of what a single LED torch uses. At that level, a small photovoltaic strip in direct sunlight is comfortably sufficient; the same strip under an office ceiling light produces a fraction of it.
Why the design persists
Partly genuine engineering: the panel meaningfully extends the life of a battery that was never meant to be changed, and turns a device that would die in three years into one that lasts a decade. Partly marketing: a visible solar panel communicates 'never needs a battery' far more effectively than a datasheet, and it is very nearly true.
There is also a real design constraint. A pure solar calculator would lose its memory and its current calculation every time you put it in a bag. The cell keeps the internal state alive, which is why you can cover the panel mid-sum and the number stays on screen.
The takeaway The panel is real and does useful work, but a hidden button cell is doing most of it. The reason either can cope is that the whole machine runs on roughly ten microwatts.
Why two calculators give different answers
Type the same thing into two calculators and you can get two different numbers. Neither is broken. They have made different, defensible choices about what your keystrokes meant and about digits you are not being shown.
Order of operations
Enter 2 + 3 × 4. A basic four-function calculator evaluates as you type: it has already computed 2 + 3 = 5 by the time you press ×, so it answers 20. A scientific calculator waits until you press equals, applies standard precedence, and answers 14. Both are behaving exactly as designed.
| Entry | Four-function | Scientific | Why |
|---|---|---|---|
| 2 + 3 × 4 | 20 | 14 | Immediate execution vs precedence |
| −3² | 9 | −9 | Whether the minus binds before the power |
| 6 ÷ 2(1+2) | 9 | 1 or 9 | Implicit multiplication precedence varies |
| 2 + 3 = = | 8 | Varies | What repeating equals is taken to mean |
The 6 ÷ 2(1+2) case is genuinely ambiguous rather than a bug. Some manufacturers treat implied multiplication as binding tighter than division, giving 1; others treat it as ordinary multiplication, giving 9. There is no universal convention, which is why the expression periodically goes viral and why anyone writing it seriously would add brackets.
Guard digits: the ones you are not shown
A ten-digit calculator does not work to ten digits. Internally it keeps two or three extra — guard digits — and rounds only at the moment of display. This prevents small errors accumulating through a long calculation and makes results look as clean as a human expects.
This is also why a calculator can appear to contradict itself. Compute something that displays as 2, subtract 2, and you may see a tiny non-zero remainder — the guard digits were never quite zero, and subtracting exposed them.
The famous ones
Early calculators had genuine, documented errors. Several 1970s models returned slightly wrong values for certain logarithms. The original Pentium processor's floating-point division bug in 1994 produced wrong answers for a specific set of values and cost Intel around 475 million dollars in replacements.
Modern calculators are, for practical purposes, correct. The remaining disagreements are almost entirely about interpreting what you typed, not about arithmetic — which is a reassuring place for the problem to have ended up.
The takeaway Seven steps, logic gates, a rotating vector and a display that emits no light — and the only thing likely to give you a wrong answer is disagreeing with the machine about what you meant by the buttons you pressed.