Why Computers Use Only Two Digits
This is the first article of the Digital Design and Verilog course. Before we get to counting in binary, converting bases, or any Verilog, I want to answer a question that is often skipped: why do computers use only two digits in the first place?
While you read this, billions of transistors in your processor are switching between two states. Every photo, song and spreadsheet that has ever been on a computer is made of those two states and nothing else. It sounds like a trick, but it is a deliberate engineering decision, and it rests on physics, on mathematics, and on one master’s thesis from 1937.
Voltage is noisy
A transistor is, for our purposes, a voltage-controlled switch. Apply a voltage to its gate and current either flows or it does not. The transistor does not care about fine gradations.
Suppose you wanted to store one decimal digit, 0 to 9, in a single electronic element. You would need ten distinguishable voltage levels: perhaps 0 V for 0, 0.5 V for 1, 1.0 V for 2, and so on up to 4.5 V for 9. In a world with no noise that would work.
Real circuits sit in a soup of interference: ripple on the power supply, switching noise from neighbouring circuits, thermal noise in every resistor. All of it adds and subtracts small voltages from your signal all the time.
Think of measuring a person’s height from their shadow on a windy day. If you have to sort people into ten one-centimetre buckets, a small gust moves the shadow enough to change the answer. If you only need to know tall or short, the gust has to be enormous before it matters.
That is the noise margin argument. With ten levels spaced 0.5 V apart on a 5 V supply, a noise spike of 250 mV corrupts a digit. With two levels, LOW near 0 V and HIGH near the supply, you have a volt or more of margin before anything goes wrong. And there is a second benefit: digital gates restore the signal. A gate that receives a slightly degraded HIGH puts out a clean HIGH. The signal is regenerated at every stage, so noise does not accumulate along a chain of logic.
Figure 2 shows the chain: a noisy physical voltage, a threshold decision, a binary abstraction, and then logic and computation on top. Every digital system ever built has this at the bottom.
Why not three levels, or ten?
People ask this often, so it is worth answering. Ternary computers have been built. The Soviet Setun machine of 1958 used balanced ternary and was a clever design. The problem is manufacturing. A reliable three-state device is much harder to make than a two-state one. The noise margins shrink, the gates get more complicated, and the theoretical density advantage of base 3 never paid for the loss in reliability.
Decimal machines also existed in the early days, but there is no such thing as a decimal transistor. You always end up encoding the decimal digits in binary underneath. Binary coded decimal (BCD) is still used in real-time clock chips, in seven-segment display drivers, and in financial calculations where exact decimal fractions matter, but it runs on binary transistors with the bits grouped in fours.
Binary won because it matches the physics of the switch. Two states, on and off, and the mathematics lines up with the hardware.
Three people, three centuries
The mathematics did line up, but it took a long time and three people to see it.
Gottfried Wilhelm Leibniz published his Explication de l’Arithmétique Binaire in 1703. He showed that every number can be written with only 0 and 1 and that arithmetic works in that system. He was more interested in the philosophy of it, creation from nothing and unity, and there was no machinery to use the idea for another 150 years.
George Boole, a largely self-taught mathematician, published The Mathematical Analysis of Logic in 1847. He showed that logical reasoning, AND, OR and NOT, could be written as algebra on variables that take only two values. That gave a rigorous framework for two-valued systems, but Boole never connected it to any physical machine.
Claude Shannon made the connection. In his 1937 master’s thesis at MIT, at the age of 21, he showed that Boole’s algebra describes the behaviour of networks of electrical relays exactly. Relay contacts open and close, and that is AND and OR. It meant a circuit could be designed with symbols, checked with algebra and built from switches. Logic and electronics became one subject, and every digital chip since rests on that thesis. Shannon had taken a philosophy course that covered Boolean algebra and was working in a laboratory full of telephone relays. The mathematics existed; someone had to notice that it described the hardware.
Bits and bytes
With the physics and the mathematics in place, the units are simple.
A bit, short for binary digit, is one choice between two states, like one coin toss. On its own it represents two things.
A byte is 8 bits, eight coin tosses in a row, with $2^8 = 256$ possible outcomes. That is enough for every printable character on a keyboard, which is what ASCII used it for.
| Unit | Bits | Combinations |
|---|---|---|
| Bit | 1 | $2^1 = 2$ |
| Nibble | 4 | $2^4 = 16$ |
| Byte | 8 | $2^8 = 256$ |
| Word (16-bit) | 16 | $2^{16} = 65{,}536$ |
| Double word | 32 | $2^{32} \approx 4.3 \times 10^9$ |
| Quad word | 64 | $2^{64} \approx 1.8 \times 10^{19}$ |
The last row is why a 64-bit address space is so large. Your file system, your memory and your network addresses are all carved out of that.
Everything is a number
A song is sampled 44,100 times a second, each sample a 16-bit integer. The integers are stored as bits, processed by arithmetic circuits, and turned back into a voltage that moves a speaker cone. A photograph is a grid of pixels, each one three 8-bit numbers for red, green and blue. Stored, transmitted and displayed as bits.
The useful thing about digital systems is not that they use binary. It is that any information can be encoded as numbers, and any number can be encoded as bits. People sometimes hear “binary” and think “limited”. A 64-bit number has over $10^{19}$ values. That is not a limitation; it is a lot of capacity bought with cheap, fast, reliable switches.
In the next article we learn to count in binary, octal and hexadecimal, and build the habit of positional notation that every digital designer uses daily.