THRESHOLD — TECHNICAL FIELD GUIDE / ТЕХНИЧЕСКИЙ СПРАВОЧНИК
PHASECOMMON GROUND
REGIME—
STATUS—
← INDEX — FIG. 00 — EVERYTHING A COMPUTER KNOWS IS TWO VOLTAGES BOOLE, 1854

THRESHOLD
COMMON GROUND & BASIC LOGIC, FROM ONE WIRE TO A RUNNING PROGRAM

Thirteen chapters, with the actual truth tables and formulas, on why every computer only ever needs two voltages, how AND, OR, and NOT build every decision a program makes, how a chain of else-ifs and a classic FizzBuzz interview question put that logic to work, how binary numbers add and subtract with no minus sign in sight, why one well-placed IF beats a million comparisons, and how to trace a whole program, step by step, from its inputs to its consequences. Scroll to begin.

BEGIN — CHAPTER 01 →
CH.01 / 13 — COMMON GROUND

Before there's a 1 or a 0, there has to be a 0V everyone agrees on

Every voltage measurement is a comparison, not an absolute number. Saying a wire sits at 'five volts' only means something once everything else in the circuit agrees on what counts as zero — a shared reference point called ground. Every wire's voltage, high or low, is really just 'how far above ground.'

Digital logic uses that shared ground to draw a line. Anything close to ground reads as LOW — the digit 0. Anything close to the supply voltage reads as HIGH — the digit 1. A gap in between is deliberately left undefined, so a little electrical noise never flips a solid 0 into an accidental 1.

CLASSIC 5V TTL LOGIC LEVELS
LOW: 0 – 0.8V   UNDEFINED: 0.8 – 2.0V   HIGH: 2.0 – 5.0V
The undefined gap is the noise margin — the buffer that keeps a slightly noisy wire from being misread.
WIRE VOLTAGE1.40V
UNDEFINED
BIT VALUE: —
CH.02 / 13 — ONE WIRE, TWO STATES, INFINITE MEANING

One wire only ever says yes or no. Enough wires say anything.

A single wire in Chapter 1's scheme carries exactly one bit — one yes-or-no, HIGH-or-LOW. On its own, that's not very expressive. But line up several wires, and every possible combination of their states becomes a distinct pattern — and everything a computer represents, numbers, letters, colours, sound, is just a name given to one of those patterns.

Add one more wire and the number of possible patterns doubles, because every pattern the old wires could make now happens twice — once with the new wire LOW, once HIGH. That doubling is the entire reason binary matters to anyone who isn't a mathematician: it's exactly what a real wire count buys you.

STATES AVAILABLE FROM n WIRES (BITS)
N = 2ⁿ
8 wires (a byte): 2⁸ = 256 states — enough for every character in this sentence. 4 wires (a nibble): 2⁴ = 16 — exactly one hexadecimal digit.
NUMBER OF WIRES (BITS), n8
256
MILESTONE: ONE BYTE — ENOUGH FOR ANY CHARACTER IN THIS SENTENCE
CH.03 / 13 — LOGIC GATES: THE THREE YOU NEED

Every decision a computer makes reduces to three little circuits

A logic gate is a circuit with one job: look at its input voltages, and output HIGH or LOW according to a fixed rule. There are only a handful of these rules worth knowing, and just three of them — AND, OR, and NOT — are enough to build every other one, including every branch a program ever takes.

AND outputs HIGH only when both inputs are HIGH. OR outputs HIGH when at least one is. NOT simply flips whatever it's given. Pick a gate below, toggle the inputs, and watch it decide.

OUTPUT
0
CH.04 / 13 — COMBINING GATES: XOR & DE MORGAN'S LAWS

Two useful shortcuts fall out of combining AND, OR, and NOT

XOR ('exclusive or') outputs HIGH when its inputs disagree — exactly one HIGH, not both. It isn't a fourth fundamental gate; wire together an OR, an AND, and two NOTs and you get exactly the same truth table. XOR earns its own symbol only because it turns out to be exactly the circuit that adds two bits together, in Chapter 8.

De Morgan's laws are the other shortcut: negating an AND is the same as OR-ing the negations, and negating an OR is the same as AND-ing the negations. It's why 'not (raining and cold)' means exactly the same thing as 'not raining, or not cold' — in English or in silicon.

DE MORGAN'S LAWS
¬(A ∧ B) = ¬A ∨ ¬B     ¬(A ∨ B) = ¬A ∧ ¬B
∧ = AND, ∨ = OR, ¬ = NOT — the same three gates from Chapter 3, written as symbols.
CH.05 / 13 — IF, THEN, ELSE: LOGIC BECOMES A DECISION

The word “if” is a logic gate wearing different clothes

Every plain-language connective maps onto one of Chapter 3's gates: “and” / “also” / “both” is AND; “or” / “either” is OR; “not” / “isn't” is NOT. Write “if raining or night, turn on the headlights” and you've already written an OR gate — you just haven't drawn it yet.

An if/then/else statement runs that gate's output through a fork in the road: take the THEN path when the condition reads HIGH, the ELSE path when it reads LOW. Nothing new is happening electrically — it's the same gate from Chapter 3, now deciding which of two instructions actually executes.

AND
ALSO, BOTH, ADDITIONALLY
OR
EITHER, OR, ALTERNATIVELY
NOT
ISN'T, DON'T, THE OPPOSITE
IF raining OR night: headlights = ONELSE: headlights = OFF
CH.06 / 13 — ELSE-IF LADDERS: WHERE ALGORITHMS APPLY IF

Real code rarely stops at one fork — it chains them

An if/else from Chapter 5 only picks between two paths. Most real decisions need more than two, so code chains conditions into a ladder: IF, then a series of ELSE IF, then a final ELSE as the catch-all. The computer checks each rung top to bottom and stops at the first one that reads HIGH — every rung below it is skipped entirely, even if it would also have been true.

A grading scale is the classic example: a score of 85 is technically also 'at least 70' and 'at least 60,' but only the first matching rung — 'at least 80' — assigns the grade. Order matters: swap the ladder's rungs and a 95 could accidentally be graded an F. Drag the score below and watch which rung wins.

IF score >= 90: grade = "A"ELSE IF score >= 80: grade = "B"ELSE IF score >= 70: grade = "C"ELSE IF score >= 60: grade = "D"ELSE: grade = "F"
SCORE72
C
CH.07 / 13 — COUNTING WITHOUT TEN FINGERS

Decimal counts by tens because we have ten fingers. Binary counts by twos because a wire has two states.

Decimal place value is powers of ten: the digit '3' in '300' means 3×10². Binary place value works identically, just with powers of two — each bit is worth twice its neighbour, so a HIGH bit contributes its position's power of two to the total, and a LOW bit contributes nothing.

That's the entire algorithm computers use to turn a row of wires into a number humans recognise: add up the powers of two for every bit reading HIGH. Toggle the bits below — they're already set to a famous number — and watch the decimal value update live.

PLACE VALUE OF BIT POSITION i
value = 2i
Bit 0 (rightmost) is worth 1, bit 1 worth 2, bit 2 worth 4, bit 3 worth 8, and so on — doubling with every step left.
42
DECIMAL VALUE
CH.08 / 13 — ADDING IN BINARY: THE ADDER

Addition is XOR with a memory for what just overflowed

Adding two single bits needs two answers: the sum itself, and whether the result overflowed into the next column — a carry. XOR alone computes the sum (HIGH exactly when the two bits disagree, which is exactly binary addition without carrying), and AND alone computes the carry (only 1+1 overflows). That pairing is called a half adder.

A full adder just adds a third input — the carry arriving from the column before it. Chain enough full adders together, one per bit position, and you've built a circuit that adds numbers of any size, the same way every processor still does it today. Toggle two numbers below and watch it happen.

HALF ADDER
Sum = A ⊕ B     Carry = A ∧ B
NUMBER A
NUMBER B
CH.09 / 13 — FIZZBUZZ: ONE NEW OPERATOR MEETS THE LADDER

Chapter 6's ladder, run once per number, is a famous interview question

Modulo — the % operator — is the remainder left over after division: 10 % 3 is 1, because 3 goes into 10 three times with 1 left over. 'n is divisible by 3' is just shorthand for 'n % 3 equals 0.'

FizzBuzz, a famous programming-interview warm-up, is nothing more than Chapter 6's ladder run once per number: print 'FizzBuzz' if divisible by both 3 and 5, 'Fizz' if just 3, 'Buzz' if just 5, otherwise the number itself — and that double-check has to sit at the top of the ladder, or it never gets a turn. Drag N and watch the whole sequence recompute.

MODULO (REMAINDER)
a % b = remainder of a ÷ b
FOR n FROM 1 TO N: IF n % 3 == 0 AND n % 5 == 0: PRINT "FizzBuzz" ELSE IF n % 3 == 0: PRINT "Fizz" ELSE IF n % 5 == 0: PRINT "Buzz" ELSE: PRINT n
COUNT UP TO N30
CH.10 / 13 — SUBTRACTING WITHOUT A MINUS SIGN

There's no separate subtractor circuit. There didn't need to be one.

Building a whole second circuit just for subtraction would be wasteful when Chapter 8 already built an adder. Two's complement solves this: flip every bit of a number and add 1, and the result behaves exactly like its negative in every calculation. Subtracting B from A becomes adding A to (−B) — the same adder, no new hardware.

The trick also gives negative numbers a home inside ordinary bits: with 4 bits, 0111 is +7 and 1000 is −8, with everything in between falling neatly into place, and the leftmost bit doubling as a sign flag — 0 for non-negative, 1 for negative — for free.

TWO'S COMPLEMENT (NEGATE AN n-BIT NUMBER)
−x = (¬x) + 1
Example, 4 bits: +3 = 0011 → invert = 1100 → +1 = 1101 = −3.
CH.11 / 13 — BINARY SEARCH: IF APPLIED AT SCALE

Guess smarter, not harder — one well-placed IF beats a million

Searching a sorted list the naive way checks every entry until one matches — worst case, N comparisons for a list of N items. Binary search does something smarter: check the middle entry with a single IF, and depending on whether it's too high or too low, throw away half the remaining list without even looking at it.

Each comparison halves what's left, which is Chapter 2's doubling formula run in reverse — so the worst case is just how many times you can halve N before reaching 1: log₂ N, rounded up. Drag the list size below and watch the gap between 'check everything' and 'check smartly' turn enormous.

BINARY SEARCH, WORST CASE
comparisons = ⌈log₂ N⌉
Chapter 2 asked how many states n bits can reach (2ⁿ). This is that question turned around: how many halvings does it take to get from N down to 1.
LIST SIZE N1,000
CH.12 / 13 — FROM GATES TO A PROCESSOR

Everything above is already a computer. It just needs a clock and a memory.

A register is a small row of circuits that can hold a pattern of bits steady — the computer's short-term memory. A clock is a signal that ticks at a steady rate, telling every register in the machine exactly when to accept a new value, so millions of gates change in lockstep instead of racing each other into nonsense.

And the branch from Chapter 5 becomes, in hardware, a multiplexer: a gate that looks at a condition and switches which of two wires actually reaches the next register. Every if-statement any program has ever run compiles down, eventually, to one of these, ticking on somebody's clock.

CLOCK FREQUENCY
f = 1 / T
A 1 GHz clock ticks a billion times a second — a billion chances per second for every register to update.
CLOCK FREQUENCY, f1.00 GHz
1.00 ns
PERIOD BETWEEN TICKS (T = 1 / f)
CH.13 / 13 — TRACING A PROGRAM: INPUT TO CONSEQUENCE

Read a program the way a computer does: one line, one consequence, at a time

Every chapter on this page is now sitting inside one small program — inputs, an AND, a branch, subtraction, a running total. Set the two inputs below, then press STEP to walk through it one line at a time and watch every variable change in real time.

This is the whole point of learning to read logic instead of just trusting it: given any starting condition, you can now predict — line by line, without running anything — exactly what comes out the other end.

CONSOLE OUTPUT—

“The design of this treatise is to investigate the fundamental laws of those operations of the mind by which reasoning is performed.”

GEORGE BOOLE, AN INVESTIGATION OF THE LAWS OF THOUGHT, 1854