=Calculator Dad
HomeLearnHow calculators work

How a calculator works: inside the chip

What happens inside a calculator when you press a key: the chip, keypad and seven-segment display, why it counts in decimal, and how it works out sines.

Open a basic calculator and there is almost nothing inside: a keypad, a display, a battery or solar cell, and one chip. Everything the calculator knows how to do lives on that chip. Here is what it is doing when you press the keys.

The four parts

  • Power: a battery, a solar cell, or both. Solar only became practical in the late 1970s, once screens needed very little power.
  • Keypad: a grid of switches under rubber or plastic keys.
  • Display: almost always liquid crystal now. The glowing red LED screens of the early 1970s drained batteries in hours; LCDs run for months.
  • Processor chip: where the work happens.

What is on the chip

  • a keyboard scanner, which watches the keypad and turns each press into a code;
  • registers, small holding areas for the numbers currently in play;
  • permanent memory (ROM), which holds the step-by-step instructions for every operation the calculator knows;
  • an arithmetic unit, which carries out each step;
  • a little working memory (RAM). That is what the M+ key writes to.

What happens when you press 25 + 9 =

  1. You press 2, then 5. The scanner reports each key, and the digits build up in a register as 25. Each new digit shifts the others one place left.
  2. You press +. The chip remembers which operation is waiting and moves 25 into a second register.
  3. You press 9. It goes into the first register.
  4. You press =. The chip runs the addition routine from ROM on the two registers, puts 34 in the first register and sends it to the display.

A basic calculator does each operation the moment you press the next operator. That is why typing 1 + 2 × 3 = gives 9, not 7: it has already added 1 and 2 before it sees the ×. Scientific calculators hold the whole expression and apply the order of operations.

How the keypad is wired

A calculator with 40 keys does not have 40 wires to the chip. The keys sit at the crossings of a grid of rows and columns. The chip powers one column at a time, very quickly, and checks which row lights up. A key at column 3, row 2 is “7”, for example. A grid of 8 columns and 8 rows can read 64 keys with only 16 wires.

In pocket calculators, the same wires that scan the keyboard also drive the display. It is one of the tricks that let a whole calculator fit on one cheap chip.

How the display is wired

abcdefg
The seven segments, named a to g. A digit is just a pattern of lit segments: 1 is b and c; 8 is all seven.

Each digit is built from seven bars, labelled a to g, plus a decimal point. Wiring every segment of an 8-digit screen separately would need 64 connections. Instead the chip lights one digit at a time, cycling through all eight faster than the eye can follow. That needs just 8 segment lines and 8 digit lines: 16 connections instead of 64.

Seven bars are enough for the digits and a handful of letters, which is why calculators can spell words upside down but cannot show most of the alphabet.

Why it counts in decimal

Computers work in binary. Most calculators do not quite. They use binary-coded decimal (BCD): each decimal digit gets its own four-bit code, instead of the whole number being converted to base two.

This matters because many ordinary decimal fractions, like 0.1 and 0.2, cannot be written exactly in binary, just as 1/3 cannot be written exactly in decimal. A computer program using standard binary arithmetic will tell you that 0.1 + 0.2 = 0.30000000000000004. A calculator working in BCD gives 0.3, because 0.1 is exact in decimal. For a device trusted with money and measurements, that is an easy trade for a little speed.

Why 1 ÷ 3 × 3 still gives 1

Work out 1 ÷ 3 and the screen shows 0.3333333333. Multiply by 3 and you would expect 0.9999999999. Most scientific calculators show 1.

The reason is guard digits. The calculator keeps more digits than it shows. A TI-84 Plus stores numbers to 14 digits and displays at most 10; the answer inside is 0.99999999999999, which rounds to 1 on screen. HP designed the 1972 HP-35 to round internally at the 11th place for the same reason. Many cheap four-function calculators have no guard digits, which is why they really do show 0.9999999.

How it works out a sine or a logarithm

A calculator cannot look up sin 37° in a table; the table would be enormous. It cannot multiply out a long series quickly either, because early calculator chips were very slow at multiplication.

Instead many use a family of methods known as CORDIC, published by Jack Volder in 1959 for an aircraft navigation computer. The idea is to reach the answer through a series of small, fixed steps, each taken from a short list of constants stored in ROM. Every step needs only shifting digits and adding, which even a tiny chip does fast. When Hewlett-Packard explained how the HP-35 did its trigonometry, its engineers traced the method back further still, to the English mathematician Henry Briggs in 1624.

So the calculator in your drawer computes sines with a method designed for a supersonic bomber, based on one worked out by hand in the 17th century.

Quick answers

How does a calculator work?

A chip scans the keypad, stores the numbers you type in small registers, and runs step-by-step routines held in its permanent memory to add, subtract, multiply or divide them. It sends the result to a seven-segment display.

Do calculators use binary?

Their circuits are binary, but most calculators store numbers as binary-coded decimal, with each decimal digit kept separately. That avoids the small rounding errors binary causes with numbers like 0.1.

How does a calculator work out sine and cosine?

Usually with CORDIC, a method published by Jack Volder in 1959 that reaches the answer through a series of small shift-and-add steps using a short table of constants.

Why does 1 ÷ 3 × 3 equal 1 on my calculator?

Scientific calculators keep extra hidden digits. A TI-84 Plus stores 14 digits and shows 10, so 0.99999999999999 rounds to 1 on screen.

Sources

  1. Wikipedia, “Calculator”
  2. Wikipedia, “Keyboard matrix circuit”; Wikipedia, “Seven-segment display”
  3. Wikipedia, “Binary-coded decimal”
  4. Texas Instruments, TI-84 Plus guidebook, internal precision
  5. David S. Cochran, “Algorithms and Accuracy in the HP-35”, Hewlett-Packard Journal, June 1972.
  6. Wikipedia, “CORDIC”