A computer has no idea what a "7" is. Deep down it only knows two things β
on and off, 1 and 0. Yet from
nothing but switches it counts, stores your words, and paints this page. The trick is
place value: just like our decimal columns are ones, tens, hundreds, binary's columns are
1, 2, 4, 8β¦ powers of two. Flip the switches below and watch numbers appear.
1. An 8-bit register β flip the switches
Here are eight bits (binary digits), together one
byte. Each bit owns a place value β
a power of two. A bit that's on adds its place value to the total; that's all "reading binary"
is. Click a bit to toggle it. The biggest a byte can hold is
11111111 = 255.
Click some bitsβ¦
0 in decimal
Watch it roll over like an odometer
0x000b00000000
2. Beyond whole numbers β text, hex & negatives
Text is just numbers. Every character has a code (ASCII /
Unicode), and that code is stored as a byte. Type one character and watch its byte light up:
"A" β code 65 Β·
01000001 Β·
0x41
Try a vs A (differ by 32), a space, a digit like 0, or an emoji.
Hexadecimal is binary shorthand. Long binary
strings are hard to read, so we chunk the byte into two groups of 4 bits (a nibble). Four bits
have 16 combinations β exactly the 16 hex digits 0β9, AβF. So one hex digit ==
one nibble:
Negative numbers? Computers use
two's complement: the top bit becomes a sign worth β128, so the same 8
switches now span β128β¦+127. Flipping the toggle below re-reads the same register from Scene 1
as signed.
Value reads as 0
In two's complement, to negate a number you flip every bit and add 1.
3. Why binary? The short version
Base-10 vs base-2. We count in tens (probably because we have ten fingers): columns worth
1, 10, 100β¦ Computers count in twos: columns worth 1, 2, 4, 8β¦ The idea is identical β each
column is the next power of the base. 13 in base-10 is "1 ten + 3 ones"; in base-2 it's
1101 = "1 eight + 1 four + 0 twos + 1 one."
Bits & bytes. One bit is a single 1/0 β the smallest possible piece of information.
Eight bits make a byte, which holds 28 = 256 distinct values (0β255). A byte is the
usual unit for one character of text or one number.
Why two states? Hardware is reliable only when it has to tell apart two clearly
different things β high voltage vs low, charged vs not, magnetized this way vs that. Two stable states
means lots of noise can be ignored, so a "1" stays a "1." Ten distinct voltage levels would be far more
error-prone. Simplicity buys reliability.
Powers of two are everywhere. Because each bit doubles the count, capacities cluster around
powers of two: 256-color palettes, 1024 bytes β a kilobyte, 65,536 (=216) values in a
16-bit number, 4 GB being 232 bytes. When you see those "odd" round numbers, that's binary
showing through.