How Binary and Logic Gates Became Computation
How George Boole mapped human thought to two numbers, Claude Shannon proved switches could do algebra, and silicon transistors turned electric currents into logic
“How does a physical electric circuit containing nothing except voltage and switches perform arithmetic calculations and evaluate logical truth?”
Inside the microchip powering your computer or smartphone, there is no magic, no tiny mathematician, and no ghost in the machine. There is only electricity flowing through billions of microscopic switches called transistors. The bridge that connects physical electric voltage to human mathematics and abstract thought is one of the most astonishing intellectual triumphs in history. In 1854, English mathematician George Boole realized that all logical propositions could be reduced to two values: TRUE (1) or FALSE (0), evaluated through three operators: AND, OR, and NOT. For eighty years, Boolean algebra was dismissed as an ivory-tower parlor trick. Then, in 1937, a 21-year-old MIT master's student named Claude Shannon proved that physical electrical switches arranged in series and parallel evaluate Boolean equations with physical electricity. By wiring just two logic gates—an XOR gate and an AND gate—into a Half-Adder circuit, engineers proved that physical voltage can add numbers together. From that single circuit emerged every microprocessor, operating system, and artificial intelligence model on Earth.
To understand the failure modes and edge cases detailed in this piece, we recommend familiarizing yourself with these foundational mechanisms first:
If you open the casing of a modern computer microprocessor, you will not find numbers, words, images, or thoughts.
You will find a polished wafer of silicon the size of a fingernail, containing between ten billion and thirty billion microscopic components called transistors.
A transistor is not intelligent. It does not know what a movie is, what an email is, or what $2 + 2$ equals. A transistor is nothing more than a microscopic, electronically controlled light switch. It is either:
- ON (allowing electric current to flow through).
- OFF (blocking electric current from flowing).
How does an array of billions of light switches—doing nothing more profound than turning on and off—render 3D photorealistic video games, execute cryptographic bank transfers, and generate human-like prose in artificial intelligence models?
How does physical electricity become mathematical logic?
The answer is one of the most profound intellectual achievements in human history: a bridge built across two centuries connecting German philosophy, British mathematical logic, American telecommunications engineering, and quantum semiconductor physics:
THE FIVE THRESHOLDS TO DIGITAL COMPUTATION
1. Leibniz Binary 2. Boolean Logic 3. Shannon's Switches 4. The Transistor 5. The Logic Adder
(1703, Leibniz) (1854, George Boole) (1937, Claude Shannon) (1947, Bell Labs) (1950s, Digital ALUs)
Numbers represented by Logic mapped to math; Relays in series/parallel Solid-state semiconductor Logic gates add bits:
only two digits: 0 & 1 AND, OR, NOT operations evaluate Boolean algebra replaces vacuum tubes physical math is born!
The diagram below traces the five conceptual and physical stages that transformed electrical current into universal computation:
Numeric magnitudes mapped to powers of two using only digits 0 and 1.
George Boole maps propositional logic (TRUE/FALSE) to mathematical equations (AND, OR, NOT).
Claude Shannon proves electromechanical relays in series and parallel evaluate Boolean algebra.
Solid-state field-effect transistors replace vacuum tubes, switching current via microscopic gate voltages.
XOR and AND gate circuits combine into Full-Adders, executing binary addition, subtraction, and universal computation.
1. Why Computers Use Binary: The Noise Immunity Ceiling
Before exploring logic, we must confront an urgent engineering question:
$$\textbf{Why do computers use base-2 (binary) instead of base-10 (decimal)?}$$
Humans count in base-10 because we have ten fingers on our hands, as explored in How Numbers and Counting Began. Early computing pioneers in the 1940s naturally tried to build decimal electronic computers. The ENIAC (1945), the first programmable general-purpose electronic computer, was a decimal machine; it used rings of ten vacuum tubes to represent the digits 0 through 9.
Decimal electronic computers were an engineering nightmare.
Consider an electrical wire carrying voltage between 0 volts and 5 volts. If you want that wire to represent ten distinct decimal digits ($0, 1, 2, 3, 4, 5, 6, 7, 8, 9$), you must carve the voltage into ten narrow bands:
THE FRAGILITY OF A DECIMAL VOLTAGE SYSTEM (0–5V)
Digit 9: 4.5V – 5.0V ████████████████████████
Digit 8: 4.0V – 4.5V ░░░░░░░░░░░░░░░░░░░░░░░░
Digit 7: 3.5V – 4.0V ████████████████████████
Digit 6: 3.0V – 3.5V ░░░░░░░░░░░░░░░░░░░░░░░░ ◀── Electrical noise of only 0.3V
Digit 5: 2.5V – 3.0V ████████████████████████ turns a "6" into a "7"!
Digit 4: 2.0V – 2.5V ░░░░░░░░░░░░░░░░░░░░░░░░ CALCULATION CORRUPTED.
...
In the real physical world, electrical circuits are noisy:
- Power supplies fluctuate.
- Wires heat up, altering electrical resistance.
- Nearby motors and radio waves induce stray electromagnetic interference.
If a stray voltage spike of just $0.3 \text{ volts}$ hits the wire, a voltage of $3.2 \text{ V}$ (representing the digit 6) jumps to $3.5 \text{ V}$ (representing the digit 7). Your bank balance or navigational calculation is silently corrupted.
The Binary Solution: Extreme Noise Immunity
In binary, there are only two states:
THE NOISE IMMUNITY OF A BINARY VOLTAGE SYSTEM
High Voltage (3.5V – 5.0V): LOGICAL TRUE / 1 ██████████████████████████
─────────────────────────────────────────────────────────────────────────────────
Forbidden Noise Margin (1.5V – 3.5V): UNUSED BUFFER [ IMMUNITY ZONE ]
─────────────────────────────────────────────────────────────────────────────────
Low Voltage (0.0V – 1.5V): LOGICAL FALSE / 0 ██████████████████████████
In a binary system:
- Anything close to 0 volts (ground) is defined as 0 (FALSE).
- Anything close to 5 volts (or $3.3 \text{ V}$, or $1.2 \text{ V}$ in modern chips) is defined as 1 (TRUE).
- The entire middle region is an empty safety buffer.
If a circuit carrying a binary 0 ($0.2 \text{ V}$) is hit by a massive electrical noise spike of $0.8 \text{ V}$, the voltage rises to $1.0 \text{ V}$.
The receiver reads $1.0 \text{ V}$, looks at its threshold rule, and says: "Still below 1.5 volts. That is still a 0." The noise is completely discarded.
Binary is used not because base-2 is mathematically superior, but because switches that are either fully OPEN or fully CLOSED are virtually immune to physical noise.
2. George Boole: Turning Human Thought into Algebra (1854)
In 1854, an obscure, self-taught English mathematician at Queen's College, Cork, named George Boole, published a book with an ambitious title:
An Investigation of the Laws of Thought on Which Are Founded the Mathematical Theories of Logic and Probabilities
Since the days of Aristotle in ancient Greece, formal logic had been a branch of philosophy. Philosophers debated verbal syllogisms:
- All humans are mortal.
- Socrates is a human.
- Therefore, Socrates is mortal.
Boole asked a revolutionary question: Can human logical reasoning be expressed as pure mathematical algebra?
Boole proposed that logical statements (propositions) could have only one of two truth values:
- $\textbf{1} \quad = \quad \text{TRUE}$
- $\textbf{0} \quad = \quad \text{FALSE}$
He then defined three fundamental logical operations:
THE THREE FUNDAMENTAL BOOLEAN OPERATORS
Operator Symbolic Math Logical Meaning Natural Language Rule
──────────────────────────────────────────────────────────────────────────────────────────────────
AND $A \cdot B$ or $A \land B$ Conjunction ("Both must be true") Output is 1 ONLY if BOTH A and B are 1
OR $A + B$ or $A \lor B$ Disjunction ("At least one true") Output is 1 if EITHER A is 1 OR B is 1
NOT $\overline{A}$ or $\neg A$ Inversion ("Opposite") Output is 1 if A is 0; 0 if A is 1
Boole wrote truth tables defining these operations with mathematical precision:
$$\begin{array}{cc|c} A & B & A \textbf{ AND } B \ \hline 0 & 0 & 0 \ 0 & 1 & 0 \ 1 & 0 & 0 \ 1 & 1 & 1 \ \end{array} \qquad\qquad \begin{array}{cc|c} A & B & A \textbf{ OR } B \ \hline 0 & 0 & 0 \ 0 & 1 & 1 \ 1 & 0 & 1 \ 1 & 1 & 1 \ \end{array} \qquad\qquad \begin{array}{c|c} A & \textbf{NOT } A \ \hline 0 & 1 \ 1 & 0 \ \end{array}$$
For more than eighty years, Boole’s algebra was treated as an eccentric mathematical novelty. It was taught in university philosophy departments as a dry exercise in symbolic notation. Nobody suspected that Boole had written the blueprint for every computer that would ever exist.
3. Claude Shannon: The Master's Thesis That Changed the World (1937)
In 1936, a twenty-one-year-old mathematics and engineering student named Claude Shannon arrived at the Massachusetts Institute of Technology (MIT).
Shannon was hired to operate the Differential Analyzer—a monstrous, room-sized mechanical analog computer built by Vannevar Bush. The machine used spinning discs, gears, and shafts to solve differential equations. To configure the machine, Shannon had to manually rewire complex banks of electromechanical telephone relays.
A relay is an electrical switch operated by an electromagnet:
- When you send current through a coil, a magnetic field pulls an iron arm, snapping two copper contacts together: the switch CLOSES (current flows).
- When you turn off the coil, a spring pulls the arm back: the switch OPENS (current stops).
THE ANATOMY OF AN ELECTROMECHANICAL RELAY
Control Wire (Input)
│
▼
┌─────────────────┐
│ Electromagnet │ ──▶ Magnetic field pulls iron arm!
│ (Wire Coil) │
└─────────────────┘
│
▼
[ Iron Armature Pivot ]
│
──────────────────┴────────────────── Conducting Path (Output)
Switch OPEN (0: No current flows)
Switch CLOSED (1: Current flows through!)
During his summer break in 1937, Shannon took a course in philosophy and encountered George Boole’s forgotten 1854 algebra.
Shannon had a flash of divine insight.
He realized that an electrical switch and a Boolean proposition were isomorphic—they had the exact same mathematical structure:
- An open switch is 0 (FALSE).
- A closed switch is 1 (TRUE).
In his 1937 master’s thesis, titled A Symbolic Analysis of Relay and Switching Circuits, Shannon proved that physical electrical switches arranged in basic circuits natively execute Boolean algebra:
1. Switches in Series = The AND Gate
Connect two switches in a line along the same wire, one after the other:
THE SERIES CIRCUIT (AND GATE)
Battery (+) ────[ Switch A ]────[ Switch B ]────( Light Bulb )──── Ground (-)
Will the light bulb turn ON?
- If Switch A is open (0) and Switch B is closed (1): NO current flows (0).
- If Switch A is closed (1) and Switch B is open (0): NO current flows (0).
- Current flows ONLY if Switch A is closed AND Switch B is closed!
Output = A AND B
2. Switches in Parallel = The OR Gate
Connect two switches on parallel branches of the wire:
THE PARALLEL CIRCUIT (OR GATE)
┌───[ Switch A ]───┐
Battery (+) ─────────┤ ├────────( Light Bulb )──── Ground (-)
└───[ Switch B ]───┘
Will the light bulb turn ON?
- If Switch A is closed (1): Current flows through the top wire (1).
- If Switch B is closed (1): Current flows through the bottom wire (1).
- Current flows if EITHER Switch A is closed OR Switch B is closed!
Output = A OR B
3. The Inverter = The NOT Gate
Wire a relay so that activating the electromagnet pulls the contacts apart rather than pushing them together:
- When input is 0 (no current to coil): Spring keeps switch CLOSED $\rightarrow$ Output is 1.
- When input is 1 (current to coil): Magnet pulls switch OPEN $\rightarrow$ Output is 0.
Shannon had unified electrical engineering and mathematical logic in a single stroke:
$$\textbf{Electric Voltage} ;;+;; \textbf{Switches} \quad \equiv \quad \textbf{Boolean Pure Logic}$$
You did not need to build complex mechanical gears to do logic. You could build circuits that evaluate propositions at the speed of electrical conduction.
4. The Silicon Transistor: Eliminating the Moving Parts (1947)
Shannon's thesis used mechanical telephone relays. Relays were revolutionary, but they suffered from three physical bottlenecks:
- Mechanical Slowness: It takes several milliseconds for an electromagnet to physically drag a metal arm across space.
- Physical Wear: Moving metal arms spark, fatigue, oxidize, and break after a few million clicks.
- The "Bug" Crisis: In September 1947, engineers working on the Harvard Mark II computer found that the machine had failed. When they inspected Relay #70 in Panel F, they found a two-inch moth trapped between the electrical contacts. Operator Grace Hopper taped the moth into the logbook with the note: "First actual case of bug being found." (Origin of the term "debugging").
The vacuum tube replaced moving metal parts with electrons flying through glass bulbs, but vacuum tubes were hot, consumed enormous power, and burned out like lightbulbs every few hours.
The salvation of computing arrived in December 1947 at Bell Laboratories in New Jersey, when John Bardeen, Walter Brattain, and William Shockley invented the solid-state transistor.
THE MOSFET FIELD-EFFECT TRANSISTOR AS A SWITCH
GATE (Control Voltage Input)
│
▼
┌─────────────────┐
│ Metallic Gate │
├─────────────────┤
│ Silicon Dioxide │ (Insulator Layer: SiO2)
├─────────────────┤
SOURCE ───────────────────▶ │ p-type Silicon │ ◀─────────────────── DRAIN
(Current Enters) │ Conducting │ (Current Exits)
│ Channel │
└─────────────────┘
Voltage on Gate = 0V: No channel forms; insulator blocks current. ──▶ SWITCH IS OFF (0)
Voltage on Gate = +1V: Electric field attracts electrons, creating ──▶ SWITCH IS ON (1)
a conducting bridge between Source and Drain!
In a modern MOSFET (Metal-Oxide-Semiconductor Field-Effect Transistor):
- There are zero moving parts.
- The switch is built from crystalline silicon doped with trace chemical impurities (phosphorus or boron) to alter its electrical conductivity.
- Applying a tiny voltage to the Gate creates an electric field that opens a microscopic conductive channel between the Source and the Drain.
A modern silicon transistor can switch on and off several billion times per second ($>3 \text{ GHz}$), measures less than five nanometers across (narrower than a strand of human DNA), and consumes minuscule amounts of power.
5. Building the Logic Gates: The Standard Symbols
Using transistors, electrical engineers created standardized, modular building blocks called logic gates.
Each gate takes one or more binary inputs (voltages) and outputs a single binary voltage:
THE SEVEN FUNDAMENTAL LOGIC GATES
Gate Name ANSI Logic Symbol Boolean Function Truth Table Summary
──────────────────────────────────────────────────────────────────────────────────────────────────
AND ┌─────) $Y = A \cdot B$ Output 1 only if BOTH are 1
│ AND )── (00->0, 01->0, 10->0, 11->1)
└─────)
OR ┌────\ $Y = A + B$ Output 1 if AT LEAST ONE is 1
) OR )── (00->0, 01->1, 10->1, 11->1)
└────/
NOT ──▷o── $Y = \overline{A}$ Inverts input
(Inverter) (0->1, 1->0)
NAND ┌─────)o $Y = \overline{A \cdot B}$ AND followed by NOT
(Universal) │ NAND )── (00->1, 01->1, 10->1, 11->0)
└─────)
NOR ┌────\ o $Y = \overline{A + B}$ OR followed by NOT
(Universal) ) NOR )── (00->1, 01->0, 10->0, 11->0)
└────/
XOR )┌────\ $Y = A \oplus B$ Output 1 if inputs are DIFFERENT!
(Exclusive) )) XOR )── (00->0, 01->1, 10->1, 11->0)
)└────/
The Magic of NAND: The Universal Gate
Notice NAND (Not-AND) and NOR (Not-OR).
In 1913, American philosopher Henry M. Sheffer proved a stunning theorem: You do not need all seven gates to build a computer. You can build every logic gate in existence—AND, OR, NOT, XOR, registers, and memory—using nothing except NAND gates.
- Wire both inputs of a NAND gate together: you get an inverter (NOT).
- Put a NOT gate after a NAND gate: you get an AND gate.
- Invert the inputs of a NAND gate using De Morgan's Law: you get an OR gate.
Every smartphone, supercomputer, and rocket guidance system can theoretically be manufactured entirely from millions of identical NAND gates connected in different wiring patterns.
6. The Mechanical Miracle: How Logic Gates Do Arithmetic (The Adder)
Now we arrive at the central mystery of computing:
$$\textbf{How do logic gates—which only know TRUE and FALSE—do actual mathematical addition?}$$
Look at how binary addition works on paper when adding two single bits ($A$ and $B$):
$$\begin{array}{r@{\quad}l@{\qquad}l} 0 + 0 = 0 & (\text{Sum } = 0, & \text{Carry } = 0) \ 0 + 1 = 1 & (\text{Sum } = 1, & \text{Carry } = 0) \ 1 + 0 = 1 & (\text{Sum } = 1, & \text{Carry } = 0) \ 1 + 1 = 10_2 & (\text{Sum } = 0, & \text{Carry } = 1) \end{array}$$
Now extract the truth tables for the Sum column and the Carry column:
$$\begin{array}{cc|c|c} A & B & \textbf{Sum} & \textbf{Carry} \ \hline 0 & 0 & 0 & 0 \ 0 & 1 & 1 & 0 \ 1 & 0 & 1 & 0 \ 1 & 1 & 0 & 1 \ \end{array}$$
Look at those two columns with the eyes of a logic designer:
- Look at the Sum column: It outputs $0$ when both inputs are the same ($00$ or $11$), and outputs $1$ when the inputs are different ($01$ or $10$). $$\textbf{That is the exact truth table of an XOR (Exclusive OR) gate!}$$
- Look at the Carry column: It outputs $1$ only when both inputs are $1$. $$\textbf{That is the exact truth table of an AND gate!}$$
The Half-Adder: Electricity Does Math
By wiring one XOR gate and one AND gate together, you construct a circuit called the Half-Adder:
THE HALF-ADDER CIRCUIT DIAGRAM
Input A ──────┬─────────────────)┌────\
│ )) XOR )─────▶ SUM Bit (S)
Input B ──────┼───────┬─────────)└────/
│ │
│ │
└───────┼─────────┌─────)
│ │ AND )─────▶ CARRY Bit (C)
└─────────└─────)
Apply 5 Volts (1) to Input A, and 5 Volts (1) to Input B:
- The XOR gate outputs 0 Volts (0) on the SUM wire.
- The AND gate outputs 5 Volts (1) on the CARRY wire.
- Total binary output: "1 0" (which is decimal 2!).
When you apply electrical voltages to Inputs A and B, the electrons flow through the transistors, and within less than a nanosecond, the mathematically correct binary sum appears as voltages on the output wires.
No human was thinking. No brain was calculating. The physical geometry of the semiconductor gates inevitably forced the electrons into the configuration of mathematical truth.
7. The Full-Adder: Adding Large Numbers
The Half-Adder is called "half" because it can only add two bits. It cannot accept an incoming carry bit ($C_{\text{in}}$) from a previous column.
To add multi-digit numbers (like $1011_2 + 1101_2$), you must combine two Half-Adders and one OR gate to build a Full-Adder:
THE FULL-ADDER LOGIC BLOCK
Input A ───┐
Input B ───┼───[ FULL ADDER ]────▶ SUM (S)
Carry In (C) ─┘ │
▼
Carry Out (C_out)
Now take eight Full-Adders and line them up side-by-side:
- Connect the Carry Out ($C_{\text{out}}$) of Adder 0 to the Carry In ($C_{\text{in}}$) of Adder 1.
- Connect the Carry Out of Adder 1 to the Carry In of Adder 2.
- Continue across all eight bits.
You have just built an 8-Bit Ripple-Carry Adder:
THE 8-BIT RIPPLE-CARRY ADDER ARCHITECTURE
A7 B7 A6 B6 A5 B5 A1 B1 A0 B0
│ │ │ │ │ │ │ │ │ │
┌▼──▼─┐ ┌▼──▼─┐ ┌▼──▼─┐ ┌▼──▼─┐ ┌▼──▼─┐
C8 ◀─┤ FA7 ├─ C7 ◀─┤ FA6 ├─ C6 ◀─┤ FA5 ├─ ... ─── C2 ◀───┤ FA1 ├─ C1 ◀─┤ FA0 ├─ C0 (0)
└─┬───┘ └─┬───┘ └─┬───┘ └─┬───┘ └─┬───┘
▼ ▼ ▼ ▼ ▼
Sum 7 Sum 6 Sum 5 Sum 1 Sum 0
Feed any two 8-bit numbers (from 0 to 255) into the input wires as patterns of high and low voltages.
The carry signal ripples through the chain like a wave, and within two nanoseconds, the exact 8-bit sum appears on the output pins.
What About Subtraction, Multiplication, and Division?
Once logic gates can add, they can perform all of mathematics:
- Subtraction: Computers do not subtract. They invert the subtrahend using NOT gates, add 1 (a mathematical trick called Two’s Complement), and feed it into the adder circuit. Subtraction is physically performed as addition: $$A - B \quad = \quad A + (\overline{B} + 1)$$
- Multiplication: Multiplication is simply repeated addition and left bit-shifts.
- Division: Division is repeated subtraction and right bit-shifts.
By clustering thousands of adders, inverters, and multiplexers together, engineers construct the Arithmetic Logic Unit (ALU)—the calculating engine at the core of every central processing unit.
8. Summary: The Ladder of Abstraction
The entire digital world is a hierarchy of abstraction layers. Each layer completely hides the messy physical mechanics of the layer beneath it:
┌──────────────────────────────────────────────────┐
│ SOFTWARE / AI / APPS (Python, Web, Neural Nets)│
├──────────────────────────────────────────────────┤
│ INSTRUCTION SET ARCHITECTURE (Opcodes, x86/ARM)│
├──────────────────────────────────────────────────┤
│ MICROARCHITECTURE (ALU, Registers, Buses, PC) │
├──────────────────────────────────────────────────┤
│ DIGITAL LOGIC GATES (NAND, XOR, Adders, Latches)│
├──────────────────────────────────────────────────┤
│ SEMICONDUCTOR PHYSICS (Transistors, Silicon) │
├──────────────────────────────────────────────────┤
│ ELECTROMAGNETISM (Electrons, Voltage, Current) │
└──────────────────────────────────────────────────┘
When you write an instruction in code or prompt an AI model, you do not need to worry about silicon atoms, voltage thresholds, or Boolean truth tables.
Yet underneath every layer of software, the fundamental truth remains: human mathematics is running across physical circuits mapped to the laws of George Boole and Claude Shannon.
In our next and final foundational explainer, How a CPU Executes an Instruction, we trace how these logic gates and adders combine with memory registers and a synchronized clock to execute computer code. To explore the quantum mechanics of how treated silicon crystals conduct or block electrons, see How Semiconductors and Transistors Actually Work. To see how these gates and adders orchestrate clock cycles into machine code, continue to How a CPU Executes an Instruction, and discover how billions of bits are held in volatile capacitor grids in How Computer Memory (RAM) Actually Works.
Where to Go From Here
Explore companion architectures or dive deeper into downstream mechanisms.
How a CPU Executes an Instruction
When software code says 'c = a + b', what physical pathway does an electrical signal actually travel through inside a microprocessor chip?
How Binary Arithmetic Logic Units Actually Add Numbers
How does an Arithmetic Logic Unit add two 64-bit binary numbers in a fraction of a nanosecond when carry bits must travel across 64 consecutive stages?
Verified Specifications & Architectural References
This explainer is grounded in primary-source engineering specifications, regulatory circulars, and standard documentation.
A Symbolic Analysis of Relay and Switching Circuits
Shannon's landmark MIT master's thesis proving that two-valued Boolean algebra can be physically implemented using electrical switching circuits.
An Investigation of the Laws of Thought on Which Are Founded the Mathematical Theories of Logic and Probabilities
The founding text of Boolean algebra, establishing the mathematical calculus of propositions using values 0 and 1.
Code: The Hidden Language of Computer Hardware and Software
The definitive pedagogical breakdown of how physical switches, telegraph relays, and logic gates assemble into arithmetic logic units and computers.
Computer Organization and Design: The Hardware/Software Interface
The gold-standard university textbook on digital logic design, ALU architectures, and microprocessor pipelines.