Analog vs digital
Think about a dimmer switch on a lamp. As you slide it, the light glides smoothly through every possible brightness — dim, a little brighter, brighter still — with no steps in between. That is an analog signal: a value that can be *anything* across a continuous range, like the volume of your voice or the height of a wave on the sea.
A digital signal throws away all that in-between richness on purpose. Instead of infinite shades, it allows just two levels — call them high and low, or 1 and 0. It is less like a dimmer and more like a plain on/off light switch: the bulb is either lit or dark, with nothing in the middle.
Why give up all that detail? Because of noise. Wires pick up stray electrical wiggles the way a microphone picks up background hiss, so the voltage carrying your signal is always a little smudged. For an analog value, every smudge changes the answer. But if the rule is just "clearly-high counts as 1, clearly-low counts as 0," with a comfortable gap in between, a smudge of a few percent doesn't matter at all — the receiver still reads a clean 1 or a clean 0. Squeezing the world into two crisp choices is what makes digital so sturdy.
Logic gates
Once the world is just 1s and 0s, you need tiny machines that *do something* with them. Those machines are logic gates, and each one follows a stubbornly simple rule: take one or two bits in, push one bit out. The three you'll meet first are AND, OR, and NOT.
They behave the way the plain English words suggest. An AND gate outputs 1 only when *both* inputs are 1 — like a door that opens only if two people turn their keys at once: 0 AND 0 gives 0, 1 AND 0 gives 0, but 1 AND 1 gives 1. An OR gate outputs 1 if *either* input is 1, like a lamp wired to two switches — 0 OR 0 gives 0, but 1 OR 0 gives 1. A NOT gate is the lone contrarian: feed it 1 and it spits out 0; feed it 0 and it spits out 1.
And what are these gates actually *made* of? Mostly transistors — minuscule electrical switches with no moving parts, each flicked on or off by the voltage on a control wire. Wire a couple of transistors together one way and they obey the AND rule; wire them another way and you get OR or NOT. A modern chip packs billions of these switches, so it has billions of gates to play with.
Boolean truth
Here is the quiet trick that ties it all together. Long before computers existed, a mathematician named George Boole worked out the algebra of true and false — a way to *calculate* with statements the way you calculate with numbers. We now call it Boolean algebra, and its whole universe has just two values. If you let true stand for 1 and false for 0, Boole's true/false math and your gates' 1/0 behavior are exactly the same thing wearing different clothes.
That match-up is the bridge from electricity to thought. Because Boolean algebra is a real branch of math, anyone can sit down with pen and paper and *prove* what a tangle of gates will do — no soldering iron required. And mathematicians long ago showed that those three humble operations, AND, OR, and NOT, are enough to express any true/false rule you can imagine, no matter how elaborate.
Stack enough gates and the simple choices start adding up — literally. Here is the heart of it: a rule that adds two single bits and reports both the result and whether it "carried over." Read it as plain Boolean logic, and notice that the whole thing is just AND, OR, and NOT in disguise.
sum = (A OR B) AND NOT (A AND B) // 1 when exactly one input is 1 carry = A AND B // 1 only when both inputs are 1 // 0 + 0 -> sum 0, carry 0 // 1 + 0 -> sum 1, carry 0 // 0 + 1 -> sum 1, carry 0 // 1 + 1 -> sum 0, carry 1 (i.e. binary 10, "two")
Memory: the flip-flop & the clock
Gates are brilliant at *reacting*, but they have no memory — change the inputs and the output instantly forgets what it just was. A computer that can't remember anything is useless, so we need a circuit that can hold on to a bit until told otherwise. That circuit is the flip-flop.
A flip-flop is a clever loop of a few gates that feed back into each other, so they prop their own output up and keep it steady — picture a light switch that stays flipped where you left it. Each flip-flop remembers exactly one bit: a single 1 or 0. Line up eight of them and you can store a number; line up billions and you have the memory your programs live in.
But if a million flip-flops all updated whenever they pleased, the result would be chaos — half-finished numbers colliding everywhere. So a chip has a conductor: the clock, a voltage that flips between high and low millions or billions of times a second, tick-tock, tick-tock. Every flip-flop is told to look at its input and update only on the tick. Between ticks, everyone holds still and the gates quietly settle on their answers.
- Tick. Every flip-flop snapshots whatever bit is on its input right now and locks it in.
- Between ticks. Those held bits flow through the gates, which compute the next round of results — a sum, a comparison, the next instruction.
- Next tick. The flip-flops capture those fresh results and the whole machine steps forward together, perfectly in time.