Why two states
Inside a chip, every wire carries a voltage. Electrical noise nudges it up and down a little all the time. So a chip never needs an exact value. It only asks: is this wire near 0 V, or near the supply?
On a 74HC chip at 4.5 V, an input up to 1.35 V counts as 0, and from 3.15 V up counts as 1. The middle is a no-go gap. Outputs stay near the ends, so noise has room to spare: the noise margin.
Counting in binary
Flip a switch and its wire goes to 0 V or to the supply. The lamp shows which: dark means 0, lit means 1. A single 0 or 1 is called a bit, short for binary digit.
Put four bits in a row. Each place is worth double the place to its right: 1, 2, 4, 8. This is base 2, called binary. Everyday base 10 works the same way, with places worth 1, 10, 100.
To read a binary number, add up the place values that hold a 1. In 1011 the 8, the 2 and the 1 are lit, and the 4 is dark. 8 + 2 + 1 = 11, so binary 1011 is eleven.
Counting adds 1 to the rightmost bit. A bit that is already 1 goes back to 0 and carries 1 to the next place, like a car's mileage counter. Four bits count from 0 to 15: sixteen patterns.
Eight bits make a byte, with places up to 128. A byte has 2⁸ = 256 patterns, so it holds 0 to 255. All eight lit, 11111111, is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.
Boolean logic
In 1854 George Boole published an algebra for logic. Boolean values are only true or false, which fits two-state wires perfectly. Computers use 1 for true and 0 for false, so every bit can be a yes-or-no answer.
NOT takes one value and gives the opposite: NOT true is false, NOT false is true. A truth table lists every possible input and the result for each. NOT has one input, so its table has two rows.
AND takes two values and gives true only when both are true. Two inputs make four rows, from 0 0 to 1 1. Only the last row, true AND true, gives true.
OR gives true when A is true, when B is true, or when both are. Only false OR false gives false. With 1 as true, these rules work on bits, and chips can do them with switches.
The numbers, step by step
;; step 1/11 · two-states ;; about: Voltage meter supply (VCC) 4.5 V near 0 V → 0 (low) near 4.5 V → 1 (high) Two states far apart are easy to tell apart, even when the voltage wobbles.
Logic levels are from Texas Instruments' SN74HC00 datasheet at a 4.5 V supply: an input must be at least 3.15 V to count as 1 and at most 1.35 V to count as 0, while a lightly loaded output gives at least 4.4 V for 1 and at most 0.1 V for 0. That leaves a 1.25 V noise margin on each side. In Python, int("1011", 2) gives 11 and bin(11) gives '0b1011'. The words not, and, or are Boolean operators, and True == 1 is True because bool is a subtype of int.