A computer, right down at the hardware, is made of billions of tiny switches. Each switch is
either on or off — and, just as with
Working with values that can only be
A logic gate is a tiny electronic building block. It has one or more
inputs (each a
Almost everything is built from just three core gates: AND, OR and NOT. Each has its own standard drawn symbol, so engineers can sketch a circuit the way you'd sketch a map. Let's meet them one at a time.
An AND gate outputs
The symbol is easy to remember: the flat back and rounded "D" front make it look like a capital D for… well, it just needs both, so it's the fussy one.
An OR gate outputs
Its symbol has a curved back and a pointed front — a rounded arrowhead. Where AND is fussy, OR is generous: it says "yes" to almost everything.
A NOT gate (also called an inverter) is the simplest of all: it
has a single input and simply flips it over. A
The symbol is a triangle pointing in the direction the signal flows, with a small circle (called a "bubble") on the tip. That bubble is the key detail — in circuit diagrams a little bubble on any gate always means "and then invert the output". Miss the bubble and you've just drawn a plain buffer that does nothing at all.
If you've done any programming, these three gates will feel familiar, because they are exactly the
if statement — just built out of hardware instead of software:
&& operator.|| operator.! operator.
Treating true as false as
So when you write if (tallEnough && oldEnough), deep down the processor is
feeding those two booleans into a real AND gate and branching on its output.
George Boole was an English mathematician who, in 1854, worked out an entire algebra using only the values "true" and "false" — long before electronics existed. For nearly a century it looked like pure maths with no use. Then in the 1930s a young engineer named Claude Shannon realised Boole's true/false algebra was the perfect way to describe electrical switching circuits. That single insight is the foundation every digital computer is built on.
The classic mistake is muddling up AND and OR:
And be careful with OR itself: in Boolean logic OR is inclusive. In everyday
English "tea or coffee?" usually means one or the other, not both — but the logic OR gate
is not like that.
We've been listing each gate's behaviour as bullet points, but there's a tidier way to write down
exactly what a gate does for every possible input: a truth table. A truth
table has one row for each combination of inputs and a column for the output, so the whole rule of a
gate fits in a tiny grid. That's the perfect next step —