Foundations week. You start knowing decimal numbers. You end knowing why computers use binary, how to convert between decimal and binary, and what a bit, a nibble, a byte, and a word are.
Theme
Computers use binary not because it is the only number system, but because it is the one that maps cleanly to the thing electronics can actually do: a switch that is either off or on. One bit, two states. Everything else follows from that.
This week you work entirely by hand. No calculators for binary conversion. The point is to build the mental model from scratch, so you understand what the conversion algorithm is doing rather than delegating it to a tool.
By the end of week 1 you can convert any number under 256 between decimal and binary without a calculator, explain what two's complement is, and recognize when an 8-bit addition has overflowed.
Reading list (~1 hour)
- Petzold CODE, Ch 6 ("Our Ten Digits"): how positional notation works and why the base matters
- Petzold CODE, Ch 7 ("Alternatives to Ten"): binary and hexadecimal as alternate bases
- Petzold CODE, Ch 8 ("Bit by Bit by Bit"): what a bit is; why two states map to hardware switches
- Petzold CODE, Ch 9 (intro section only, through page ~100 in 1st ed.): the first look at negative numbers
Read Petzold slowly. He is writing for a general audience and his examples are worked out in full. Do the examples yourself before reading his answer.
Lecture outline (~2 hours)
Section 1: Positional notation and why base matters
- Decimal positional notation: units, tens, hundreds, thousands as powers of 10
- Each column is base^position, with the rightmost column as base^0 = 1
- The same idea with base 2: 1, 2, 4, 8, 16, 32, 64, 128 as the column weights
- Decimal 13 = 1x8 + 1x4 + 0x2 + 1x1 = 1101 in binary
- Practice: convert 7, 10, 42, 100, 255 to binary by the column-weight method
Section 2: Bits, nibbles, bytes, words
- 1 bit: 0 or 1, two possible values
- 4 bits (a nibble): 16 possible values (0000 through 1111)
- 8 bits (a byte): 256 possible values (0x00 through 0xFF)
- 16 bits: 65,536 possible values; 32 bits: ~4 billion; 64 bits: ~18 quintillion
- "Word" is ambiguous (16 bits on old processors; 32 or 64 bits on modern ones); context matters
- Why 8 bits per byte: historical; group of 8 became the universal unit by the 1970s
Section 3: Binary to decimal conversion
- Method 1: column weights. Write out 128, 64, 32, 16, 8, 4, 2, 1. Circle the positions with a 1 bit. Sum the circled weights.
- Method 2: double-and-add (working left to right). Start with 0. Double the running total, then add the next bit.
- Practice both methods on 10010110, 01101101, 11111111, 00000001
Browser tool: Multi-Base Number Slider. Once you have done a handful of hand conversions, use the slider to check your work. Drag the slider or type a decimal number; the page shows the same value in decimal, hexadecimal, binary, octal, and ASCII at the same time. Click any bit to flip it and watch the column-weight sum update. Do hand conversions first. The tool is for verification and intuition-building after you have built the mental model by hand, not for skipping the practice.
Section 4: Signed integers and two's complement
- Problem: how do you represent negative numbers in binary?
- Sign-and-magnitude (naive approach): leftmost bit is the sign; rest is magnitude. Problem: two representations of zero; awkward arithmetic.
- Two's complement (how computers actually do it): flip all bits, then add 1.
- For an 8-bit byte: values from -128 to +127. The leftmost bit signals "negative" as a side effect, not as an explicit sign.
- Overflow: add 127 + 1 in an 8-bit signed representation. You get -128. The result wrapped around. This is overflow: the answer does not fit in the available bits.
- Why two's complement: subtraction becomes addition. The same circuit adds and subtracts. No special cases.
Section 5: Why binary maps to hardware
- A transistor as a switch: fully on (saturation) or fully off (cutoff), not "halfway on"
- Two states map to 1 and 0 with no ambiguity; analog noise does not corrupt the value as long as it stays in the right half of the range
- This is the physical reason binary is universal in digital hardware, not a convention anyone chose arbitrarily
Labs (~90 minutes)
Lab 1.1: Binary by Hand (labs/lab-1-1-binary-by-hand.md)
- Convert 20 numbers between decimal and binary without a calculator
- Verify three of them using Python:
bin(n)andint('...', 2) - Artifact: completed worksheet committed to your Git repo
Lab 1.2: Hex Dump a File (labs/lab-1-2-hex-dump.md)
- Use
xxdorhexdump -Con a PNG file and a ZIP file - Identify the first 4 bytes of each (the "magic bytes" that identify the format)
- Artifact: annotated text file showing the magic bytes + format identified
Lab 1.3 (Tier-1 companion): Multi-Base Slider Workout (worksheets/fnd-101/lab-multi-base-slider.md)
- Drive the Multi-Base Number Slider through 15 predict-then-verify exercises (decimal -> hex, hex -> binary, hex -> ASCII)
- Walk 5 edge cases at the byte boundary (0, 255, 256, 0xff, 0x100; 8-bit vs 16-bit toggle)
- Calibrates the Lab 1.1 hand conversions and bridges into Week 2's ASCII work
- Artifact: filled worksheet, predictions made BEFORE slider observations
Independent practice (~4 hours)
- Do the 30-conversion drills at the bottom of Lab 1.1 (the lab only requires 20; push to 30 for fluency)
- Write the binary representations of 0 through 31 from memory, then check
- For the two's complement section: verify by hand that adding 127 + 1 in 8-bit two's complement gives you 0b10000000, which is -128 in signed interpretation
- Read the Wikipedia article "Two's complement" (the "Why it works" section specifically) and connect it to Petzold's Ch 9 explanation
Reflection prompts (~30 minutes)
- Before this week, did you think of numbers as having a "natural" base? After working through positional notation in base 2, does the base feel arbitrary or principled?
- You learned two methods for binary-to-decimal conversion. Which felt more natural to you? Why?
- The lecture said overflow is when the answer "does not fit in the available bits." Give an example from your own Lab 1.1 work of a calculation that overflows 8-bit signed arithmetic.
- A byte can represent 256 distinct values. Why 256, not 255 or 257?
- What is one thing from this week that you want to know more about?
What comes next
Week 2 moves from numbers to text. You will learn how computers represent characters (letters, punctuation, emoji) as numbers, and specifically how UTF-8 encodes Unicode code points into bytes. The hex-dump skill from Lab 1.2 is the core tool; you will use xxd again to decode text files byte by byte.