relay-logic

The Half Adder: How 1 + 1 = 10 Emerges From Two Relay Gates

DigiSim Relay Team DigiSim Relay Team
8 min read

In the previous post, we built a circuit that chooses — a multiplexer that uses a selector input to steer one of several signals to a single output. Every circuit in this series so far has produced a single output bit: a lamp either on or off, a truth table column that reads 0 or 1. What we have not yet done is make our relays produce a numeral.

That changes right now.

From true/false to how-many

Twelve posts of relay logic, and you can build AND, OR, NOT, NAND, NOR, XOR, XNOR, and a selector that routes between them. That is a complete toolkit for Boolean reasoning. But a computer does not only reason. It counts, adds, calculates. Somewhere between “the lamp is on” and “the answer is 42,” something fundamental shifts: instead of one output, you need two.

A single bit is 0 or 1. Two bits together represent four values — 00, 01, 10, 11 — zero through three. The moment a circuit drives two output bits simultaneously, it is no longer making a decision. It is producing a number.

The half adder is the first circuit in this series to do exactly that.

Why binary makes addition almost trivially mechanical

Before we wire anything, it’s worth sitting with the question Gottfried Wilhelm Leibniz pondered in the late 1600s, and published in his 1703 paper Explication de l’Arithmétique Binaire: why binary at all?

Decimal addition, for all its familiarity, is complex. To add two single decimal digits, you need to memorize a table with a hundred entries — every combination from 0+0 to 9+9 — and track carry rules that interact with all of them. Teaching a machine to do this requires either a large lookup table or a cascade of comparisons.

Binary addition has exactly four rules:

  • 0+0=00 + 0 = 0 (sum 0, carry 0)
  • 0+1=10 + 1 = 1 (sum 1, carry 0)
  • 1+0=11 + 0 = 1 (sum 1, carry 0)
  • 1+1=101 + 1 = 10 (sum 0, carry 1)

Four rules. No tables. No special cases beyond those four rows. That last row is the only one that surprises newcomers: 1+11 + 1 in binary equals 10, pronounced “one-zero,” not ten. In binary there is no digit for 2; the number two is written as 1 in the second column and 0 in the first, just as 10 in decimal means “one ten and zero ones.” Binary two is “one two and zero ones.”

Every rule, every row, produces at most two bits: a Sum bit for the current column and a Carry bit for the next column to the left. And when you look at those two output columns separately, you will find that you have already built both of them.

The recognition

Look at the Sum bit column: 0, 1, 1, 0. You have seen that sequence before.

It is the XOR truth table, row for row. Post 10 made this explicit: XOR fires precisely when its inputs disagree. That disagreement is, mathematically, the digit that stays in the current column. When both inputs are 1, they agree again — sum is 0 — and the 1 carries forward.

The Carry column — 0, 0, 0, 1 — is the AND truth table: the circuit from Post 4. A carry is generated only when both inputs are 1.

Sum=ABCarry=AB\text{Sum} = A \oplus B \qquad \text{Carry} = A \cdot B

The half adder is XOR and AND, driven from the same two inputs, running side by side. No new gates to learn, no new relay configurations. Assembly is the whole act.

The truth table in physical clothing

Two relay inputs, A and B. Two output lamps: one labeled Sum, one labeled Carry. Here is what happens when you try every combination:

ABSum (A ⊕ B)Carry (A · B)
0000
0110
1010
1101

Three of the four rows are unremarkable — the Sum lamp follows the single active input. The fourth row is the one worth slowing down for. When you energize both A and B, the Sum lamp goes dark and the Carry lamp lights. You added two 1s and the only output is a carry. The relays just computed 1+1=101 + 1 = 10: sum 0 in this column, carry 1 into the next.

That is not an abstraction. It is two lamps changing state in response to two coil energizations. The relays clicked, the contacts moved, and the result was the number two — expressed in binary, distributed across two output wires.

The first relay machines to add this way

Leibniz wrote out the arithmetic in 1703, marveling at how few rules binary required. He noted that all of mathematics could be encoded in the simplest possible opposition — presence and absence, 1 and 0 — and that this simplicity was philosophically remarkable. What he could not have known was that two and a half centuries later, engineers would wire his rules directly into copper and iron.

The first to do it in a serious machine was Konrad Zuse, a German civil engineer who spent the late 1930s building computers in his parents’ living room in Berlin. His Z3, completed in 1941, used approximately 2,600 electromagnetic relays — devices identical in principle to the one you toggled in Post 1 — and operated entirely in binary floating-point arithmetic. Addition was done by half adders and full adders assembled from relay contacts, clicking through exactly the four-row truth table above, column by column across each operand. It was the first programmable, relay-based computer — and it ran on the same four rules Leibniz had traced on paper.

The half adder is where philosophy became engineering.

Try it yourself

Below is a live half adder — the XOR gate wired in parallel with the AND gate from the same two inputs, running as a genuine DC circuit simulation right in your browser. Two inputs, two outputs. Before you touch anything, make a prediction: which input combination will light the Carry lamp? Which combination will light neither lamp?

A relay half adder: two inputs drive an XOR gate for Sum and an AND gate for Carry, producing the result of single-bit binary addition. Open it in the DigiSim Relay Lab.

Three things to try:

  1. Walk the truth table row by row. Start at (0, 0) and work through (0, 1), (1, 0), and (1, 1). Watch how the two lamps move independently — the Sum lamp follows XOR’s logic, the Carry lamp follows AND’s. Two separate circuits, same inputs, different questions asked simultaneously.

  2. Hold A on and flip B. A on, B dark: Sum lit, Carry dark — you’ve computed 1+0. Now energize B: the Sum lamp extinguishes and the Carry lamp fires. You added one more input and the current-column output decreased while a new column lit up. That is 1+1=101+1=10 becoming visceral rather than symbolic.

  3. Turn the sound on. The Carry lamp fires on a single click. The Sum lamp going dark at the same moment produces its own click — silence from XOR, noise from AND, arriving together. In Zuse’s Z3, a bank of relays clicking through this pattern, column by column, added two binary numbers in about half a second. A roomful of those clicks was a computer thinking.

What a pile of relays just did

Step back and notice what happened. You wired two gates — gates built from relay coils and spring-loaded contacts — and the result is a circuit that produces a two-bit binary number. The relays do not know they are doing arithmetic; they only know their coils are energized or not, their contacts open or closed. The arithmetic emerges from the arrangement.

This is the point where “digital logic” and “digital arithmetic” converge. AND is not just a logic gate anymore — it is a carry generator. XOR is not just a difference detector — it is a sum computer. The half adder is the first time in this series that the calculation interpretation wins. Charles Petzold makes exactly this moment the hinge of CODE: the chapter on addition is where gates stop being abstract and start being a machine that computes.

A known limitation, and a reason to go further

The half adder earns its “half” honestly. It can add two single bits, but only for the first column of a multi-bit addition. Adding a second column requires three inputs: A, B, and the carry coming in from the column to the right. The half adder has no carry-in port. It cannot chain.

The fix is the full adder — three inputs in, two outputs out. Two half adders and an OR gate assemble into one full adder. Four in a row add two 4-bit numbers; eight add bytes; cascade enough and you have the arithmetic logic unit that executes every addition your device has ever performed.

That cascade is Post 14’s story. For now, the half adder is the foundation — and it is already complete.

What you just learned — and what’s next

Post 13 adds these pieces to the series:

  • Binary addition has four rules — that’s why it maps onto hardware where a hundred decimal rules never could.
  • Sum = XOR, Carry = AND: two output bits, two gates you already built, wired from the same input pair.
  • The half adder is the first circuit that produces a numeral, not just a true/false decision — two bits, one number.
  • Konrad Zuse’s Z3 (1941) ran on exactly this pattern: relay half adders clicking through the four-row table, column by column, performing binary arithmetic as a machine for the first time.

In Post 14 of Building a Computer from Relays, we’ll fix the half adder’s one gap: no carry-in. The full adder accepts three inputs — A, B, and an incoming carry — and two half adders plus an OR gate provide exactly that. Chain four full adders and you add 4-bit numbers; chain enough and you have an ALU.

The arithmetic is just getting started. Every circuit in this series is live and waiting in the DigiSim Relay Lab.