Everything on your phone — this sentence, your last photo, the song playing, your high score — is stored as only two symbols: 0 and 1. Not because binary is elegant, but because hardware is reliable at exactly two states: voltage high or low, magnet north or south, light on or off. Two states you can distinguish cheaply and dependably, billions of times per second.
Quick challenge before we start: with 1 coin flip you can distinguish 2 outcomes. With 2 flips, 4 outcomes (HH, HT, TH, TT). With 10 flips? If you said 1,024 — or even "2 multiplied by itself 10 times" — you already understand the most-tested fact in Big Idea 2.
A bit (binary digit) is the smallest unit of data: a single 0 or 1. A byte is 8 bits.
The counting rule — the most tested fact in this unit:
n bits can represent 2ⁿ different values.
| Bits | Distinct values | Range if used for whole numbers starting at 0 |
|---|---|---|
| 1 | 2 | 0–1 |
| 2 | 4 | 0–3 |
| 3 | 8 | 0–7 |
| 4 | 16 | 0–15 |
| 8 | 256 | 0–255 |
| n | 2ⁿ | 0 to 2ⁿ − 1 |
Two directions the exam asks this:
- "How many values can 6 bits represent?" → 2⁶ = 64
- "A program must store 100 different ID numbers. What's the minimum number of bits?" → find the smallest n with 2ⁿ ≥ 100 → 2⁶ = 64 is too small, 2⁷ = 128 works → 7 bits
- Adding one bit doubles the number of representable values. (Stated exactly this way in questions.)
Binary is base 2: each position is worth a power of 2, growing right-to-left.
Binary: 1 0 1 1 0 1
Place: 32 16 8 4 2 1
Contribute: 32 + 0 + 8 + 4 + 0 + 1 = 45
So 101101₂ = 45. To convert binary → decimal: write the place values under the bits, add up the places holding a 1.
To convert 77 to binary: take the largest power of 2 that fits, subtract, repeat.
77 − 64 = 13 → 64s place: 1
13 − 8 = 5 → 8s place: 1 (32 and 16 don't fit: 0, 0)
5 − 4 = 1 → 4s place: 1
1 − 1 = 0 → 1s place: 1 (2s place: 0)
77 = 1001101₂
Verify by adding back: 64 + 8 + 4 + 1 = 77 ✓. Always verify — it takes five seconds and catches every slip.
(AP CSP uses unsigned whole numbers only — no negative binary, no two's complement, no binary fractions. If you've seen those elsewhere, park them; they're not on this exam.)
Here's the deep idea. The byte 01000001 is:
- the number 65, if read as a number
- the letter "A", if read as text (character encodings like ASCII assign numbers to characters)
- part of a color or a pixel brightness, if read as image data
- a tiny slice of sound pressure, if read as audio
The bits don't "know" what they are. Meaning comes from how the program interprets them. That's abstraction: bits at the bottom; numbers built from bits; characters, colors, and sounds built from numbers; images and songs built from those. Each level ignores the details below it. When the CED says "data abstraction," at this level it means: anything digital is ultimately bits, and higher-level representations hide that detail.
Real-world signals (sound waves, light, temperature) are analog — smooth and continuous. Computers store digital data — discrete values. The bridge is sampling: measure the analog signal at regular intervals, store each measurement as a number.
[DIAGRAM: A smooth sound wave (continuous curve). Vertical dashed lines at regular
time intervals mark sample points; at each, a dot on the curve shows the measured
value. Below, the list of measured values: 12, 19, 23, 21, 14, 6, 2, 5...
Caption: more frequent samples → closer approximation of the wave → more data.]
More samples per second and more bits per sample = a more faithful copy — and a bigger file. Digital data is an approximation of the analog original; finer sampling improves the approximation. (This trade-off returns in Lesson 4, compression.)
Computers store numbers in a fixed number of bits, so:
0.1 + 0.2 and get 0.30000000000000004 — each piece was already a tiny approximation. Calculations on approximations accumulate small errors.Exam framing: overflow = integer too large; roundoff = real (decimal) numbers stored as approximations. Different problems, different names.
Problem: What is 11010₂ in decimal?
Strategy: Place values right-to-left: 1, 2, 4, 8, 16. Add the places with 1s.
Solution:
Bits: 1 1 0 1 0
Place: 16 8 4 2 1
Sum: 16 + 8 + 0 + 2 + 0 = 26
11010₂ = 26
Interpretation: Write the places under the bits every single time. Doing it in your head is how careless errors happen under time pressure.
Problem: Convert 52 to binary.
Strategy: Greedy subtraction with powers of 2: 64 is too big, start at 32.
Solution:
52 − 32 = 20 → 1 in 32s
20 − 16 = 4 → 1 in 16s
(8 doesn't fit into 4: 0)
4 − 4 = 0 → 1 in 4s
(2s: 0, 1s: 0)
52 = 110100₂
Verify: 32 + 16 + 4 = 52 ✓
Problem: A school assigns each of its 1,000 students a unique binary ID. What is the minimum number of bits per ID?
Strategy: Smallest n with 2ⁿ ≥ 1000.
Solution: 2⁹ = 512 (too small). 2¹⁰ = 1024 ≥ 1000 ✓. 10 bits.
Interpretation: The wrong answers will include 9 (just under) and sometimes 1000/2 or other trash. Compute the powers — don't estimate.
Problem: A program stores the value 01001000 01001001 (two bytes). One part of the program displays it as the text "HI"; another part reads the first byte as the number 72. Which statement best explains this?
(A) The program contains a logic error, since data can have only one meaning (B) The same sequence of bits can represent different types of data depending on how the program interprets it (C) The bits were corrupted between the two parts of the program (D) Text data cannot be represented in binary
Solution: (B). Bits have no inherent meaning; interpretation is applied by the program. 72 happens to be the character code for "H" — the same byte, two readings, both correct.
Interpretation: This is the abstraction question, and it appears on virtually every exam form in some costume. The answer always amounts to: meaning depends on interpretation.
1101₂?1. (B). Places: 8 4 2 1 under 1 1 0 1 → 8 + 4 + 0 + 1 = 13. (A) counts the bits' face value; (C) misplaces a bit (8+4+2=14); (D) doubles the true answer (misaligned places).
2. (A). 19 − 16 = 3; 3 − 2 = 1; 1 − 1 = 0 → 10011 (16 + 2 + 1). Verify: ✓. (B) is 25, (C) is 22, (D) is 21.
3. (D). 2⁵ = 32. (C) is 5² — the classic squaring mistake. (B) is 2×5, (A) is n itself.
4. (B). Five distinct states need 2ⁿ ≥ 5. 2² = 4 (too few), 2³ = 8 ✓ → 3 bits. (A) handles only 4 states; (D) confuses "5 states" with "5 bits."
5. (B). Each added bit doubles the count: 2ⁿ⁺¹ = 2 · 2ⁿ. Stated verbatim in the CED, asked verbatim on exams.
6. (A). Max for 8 unsigned bits = 255; 300 exceeds it → overflow. (B) confuses roundoff (decimals) with overflow (too large). (C) ignores the fixed width. (D): valid code, no grammar problem.
0.1 + 0.2 may not equal exactly 0.3 in a program?7. (B). Roundoff: finite bits approximate real numbers; small errors accumulate through arithmetic. (C) misapplies overflow to a small number.
8. (B). More samples → closer approximation of the analog wave AND more data to store. Fidelity and file size rise together — the trade-off behind next lesson's compression.
9. (C). 2⁶ − 1 = 63. (D) = 2⁶ counts the values (0 through 63) — the largest value is one less. This off-by-one is the single most common wrong answer in Big Idea 2.
10. (A) and (C). (A) is meaning-from-interpretation; (C) is layers hiding detail — both are abstraction in action. (B) is false (bit-widths vary); (D) is true-ish but says nothing about abstraction.
11. (C). 32 = 100000₂ (6 bits). 31 = 11111 (5 bits), 16 = 10000 (5 bits), 15 = 1111 (4 bits). Crossing a power of 2 adds a digit — just like 999 → 1000 in decimal.
12. (B). Sampling a continuous quantity at intervals produces a digital approximation. (A)/(C) claim perfection that sampling can't give; (D) misuses overflow.
Answer letter distribution check: B, A, D, B, B, A, B, B, C, A+C, C, B — singles: A×2, B×6, C×2, D×1 + multi (A,C). Still B-leaning; Lessons 4–5 keys will deliberately rebalance toward C/D.
Binary itself won't appear in your Create PT code — but two ideas from this lesson will:
Habit: in your PT bug journal (started in Lesson 2), note any place your program deals with a number that could grow large or a decimal that could misbehave. One sentence each. Cheap insurance for WR 2(b).
1. (B). Places: 8 4 2 1 under 1 1 0 1 → 8 + 4 + 0 + 1 = 13. (A) counts the bits' face value; (C) misplaces a bit (8+4+2=14); (D) doubles the true answer (misaligned places).
2. (A). 19 − 16 = 3; 3 − 2 = 1; 1 − 1 = 0 → 10011 (16 + 2 + 1). Verify: ✓. (B) is 25, (C) is 22, (D) is 21.
3. (D). 2⁵ = 32. (C) is 5² — the classic squaring mistake. (B) is 2×5, (A) is n itself.
4. (B). Five distinct states need 2ⁿ ≥ 5. 2² = 4 (too few), 2³ = 8 ✓ → 3 bits. (A) handles only 4 states; (D) confuses "5 states" with "5 bits."
5. (B). Each added bit doubles the count: 2ⁿ⁺¹ = 2 · 2ⁿ. Stated verbatim in the CED, asked verbatim on exams.
6. (A). Max for 8 unsigned bits = 255; 300 exceeds it → overflow. (B) confuses roundoff (decimals) with overflow (too large). (C) ignores the fixed width. (D): valid code, no grammar problem.
7. (B). Roundoff: finite bits approximate real numbers; small errors accumulate through arithmetic. (C) misapplies overflow to a small number.
8. (B). More samples → closer approximation of the analog wave AND more data to store. Fidelity and file size rise together — the trade-off behind next lesson's compression.
9. (C). 2⁶ − 1 = 63. (D) = 2⁶ counts the values (0 through 63) — the largest value is one less. This off-by-one is the single most common wrong answer in Big Idea 2.
10. (A) and (C). (A) is meaning-from-interpretation; (C) is layers hiding detail — both are abstraction in action. (B) is false (bit-widths vary); (D) is true-ish but says nothing about abstraction.
11. (C). 32 = 100000₂ (6 bits). 31 = 11111 (5 bits), 16 = 10000 (5 bits), 15 = 1111 (4 bits). Crossing a power of 2 adds a digit — just like 999 → 1000 in decimal.
12. (B). Sampling a continuous quantity at intervals produces a digital approximation. (A)/(C) claim perfection that sampling can't give; (D) misuses overflow.
Answer letter distribution check: B, A, D, B, B, A, B, B, C, A+C, C, B — singles: A×2, B×6, C×2, D×1 + multi (A,C). Still B-leaning; Lessons 4–5 keys will deliberately rebalance toward C/D.
Exam tip: Before the exam, hand-write the powers of 2 from 2⁰ to 2¹⁰ (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024) on your scratch paper the moment the exam starts. Every binary question on the form becomes lookup + addition.