Everything Is a Number
Tap the board to zoom inClick the board to zoom in
Lessons that use this board
EVERYTHING IS A NUMBER
How Computers Work · 01 — bits, bytes, and how ONE pattern of switches becomes text, numbers & colour
a computer knows exactly ONE trick: a switch that is ON or OFF. that's a BIT (1 or 0). stack eight of them = a BYTE. everything above is just bytes, INTERPRETED.
1 · A BIT, THEN A BYTE
a BIT = one switch (a transistor): 1 = on / high voltage, 0 = off / low. that's the whole alphabet.
line up 8 bits = 1 BYTE = 256 possible patterns (0 – 255). each slot has a PLACE VALUE:
128
0
64
1
32
0
16
0
8
0
4
0
2
0
1
1
add the ON columns:
64 + 1 = 65
so the byte 01000001 is the number 65. binary is just base-2 with the same place-value idea as base-10.
why 8? it's the smallest chunk the machine addresses as a unit — the atom of memory. (a WORD = a few bytes, later.)
counting in binary: 0, 1, 10, 11, 100, 101, 110, 111, 1000 ... (each new digit = double the range).
0000=0 0001=1 0010=2 0011=3 0100=4 0101=5 0110=6 0111=7 1000=8
2 · HEX — the human shorthand for bytes
binary is long to read. group 4 bits = a NIBBLE = ONE hexadecimal digit (base 16, 0–F).
so 2 hex digits = exactly 1 byte. this is why hex is everywhere.
0100 0001
4
1
→ 0x41 = 65
the hex digits past 9:
A=10 B=11 C=12 D=13 E=14 F=15
you already read hex every day:
· colours (#1E1E1E) · memory addresses (0x7ffe...)
· byte dumps, hashes, MAC addresses, UUIDs
1 byte = 2 hex = 8 bits = 0 to 255 = 0x00 to 0xFF. burn that chain in.
3 · THE BIG IDEA: one byte, many meanings
the bits don't KNOW what they are. meaning is imposed by the TYPE — the agreement on how to read them.
0100 0001
the very same byte can be...
· the NUMBER 65
· the letter 'A' (ASCII: A=65, a=97, '0'=48)
· one channel of a colour
· a CPU instruction, a pixel, a flag...
"there is no text or number 'on the wire' — only bytes plus an agreement on how to interpret them."
(exactly the lesson from the DNS telegram & DDIA encoding — this is where it bottoms out.)
TEXT
ASCII = 1 byte per character (English).
UNICODE / UTF-8 = 1–4 bytes (é, 中, 😀) so
the whole world's writing fits.
COLOUR
RGB = one byte each for Red, Green, Blue.
#1E1E1E = (30, 30, 30)
#1971C2 = this board's blue
...so a file is just bytes + a rule.
a .txt says 'read me as ASCII'.
a .png says 'read me as pixels'.
a .mp3 says 'read me as sound'.
the file EXTENSION / header is that
agreement, nothing more. rename
.png to .txt and the bytes don't
change — only how you READ them.
4 · HOW BIG, AND WHICH WAY ROUND
WORD SIZE — how many bits the CPU grabs at once:
32-bit vs 64-bit. it also sets the ADDRESS SPACE: 32-bit can
address ~4 GB of RAM; 64-bit addresses ~16 exabytes. that's
the real reason your machine is '64-bit'.
ENDIANNESS — byte order of a multi-byte number:
· BIG-endian: most-significant byte first (human order).
it's 'network byte order' — callback to Networking!
· LITTLE-endian: least-significant first (x86 / your laptop).
0x12345678 -> BE: 12 34 56 78 LE: 78 56 34 12
UNITS (and a classic gotcha):
· bit = b · byte = B (8 bits)
· KB, MB, GB, TB (×1000) vs KiB, MiB (×1024)
your '100 Mbps' internet is mega-BITS/s →
÷8 ≈ 12.5 MB/s of actual download. bits vs bytes bites everyone.
JARGON, DECODED
bit = one 0/1 switch · byte = 8 bits (0–255) · binary = base 2 · hexadecimal = base 16 (0–F), 1 hex digit = 4 bits (a nibble), 2 hex = 1 byte
ASCII = 1-byte character code (A=65) · Unicode / UTF-8 = variable-length code for all writing · RGB = red/green/blue, one byte each · type = the agreement on how to read bytes
word size = bits the CPU handles at once (32/64-bit) → also the address space · endianness = byte order of a multi-byte value (big = network order, little = x86)
bit (b) vs byte (B) — network speeds are in bits! · KB (×1000) vs KiB (×1024) · nibble = 4 bits · the whole chain: 1 byte = 2 hex = 8 bits = 0–255 = 0x00–0xFF
Saved in this browser only.