← Back to Blake's Home

Lesson 23: Binary, Hex & Decimal — Practice Day

You know the rules. Today we drill them until they're instant.

May 2026 ~45 min Number Systems — Practice Focus SE-11-02 · SE-11-08

How this lesson works. You already get binary and hex at the surface — what you need now is speed and a few new ways of seeing the same number. Each section gives you one new lens, then a drill block. Don't peek at the reveals until you've written your answer down. Aim to do every problem; if a question feels obvious, that's the goal — you're meant to outgrow these.

1. New Lens: "Three Faces of One Number" ~3 min

A number doesn't belong to one base. The value fifteen exists by itself — decimal, binary, and hex are just three different costumes it can wear. Same person, different outfit.

DecimalBinaryHexWhat to notice
00000 000000all zero in every base — easy anchor
150000 11110Fone full nibble of 1s — biggest single hex digit
160001 000010Hex "10" is decimal 16, not 10. "10" means "I rolled over". Each base rolls at a different number.
420010 10102Anotice how binary's two nibbles map exactly to the two hex digits
1281000 000080a single high bit — that's the sign bit position in a signed byte
2551111 1111FFevery bit on — biggest value an unsigned byte can hold
2561 0000 0000100one bit beyond a byte — hex "100" looks like decimal 100 but isn't

The trap to break. When you see 10 you read "ten". When the computer sees 10 in binary it reads "two". When a colour code says 10 in hex it reads "sixteen". The digits are identical — only the base tells you what they mean. Always check the base before you read.

2. New Lens: The Odometer ~3 min

Imagine a car odometer — except instead of just one (base-10), you've got three rolling at once. Decimal rolls every 10. Binary rolls every 2. Hex rolls every 16. Watch them tick together:

DecBinHex
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
101010A
111011B
121100C
131101D
141110E
151111F
161 000010
171 000111

What to take away: the binary column rolls over every two ticks. The hex column rolls every sixteen — which is also the moment binary gains a fifth digit. That's the whole reason hex and binary are siblings: a new hex digit is born at the exact same instant binary needs a new nibble.

3. Powers of 2 — The Reflex You Want ~2 min

Memorise these. Not because the syllabus says so, but because every binary conversion gets fast the second you don't have to compute them. Top row is the exponent, middle is the value, bottom is the hex form.

2⁰
1
0x1
2
0x2
4
0x4
8
0x8
2⁴
16
0x10
2⁵
32
0x20
2⁶
64
0x40
2⁷
128
0x80
2⁸
256
0x100
2⁹
512
0x200
2¹⁰
1024
0x400

Pattern worth seeing: every time the exponent jumps by 4, the hex form gains a zero — 2⁴=0x10, 2⁸=0x100, 2¹²=0x1000. That's the four-bits-per-hex-digit rule in action. If you ever forget a power of 2, count up from the nearest one you know.

4. Drill Block A — Conversion Sprint ~12 min

SE-11-02 — All six conversion directions

🎯 15 problems, all directions. Write your answer first, then reveal.

Each tag tells you the input base. Aim for under 1 minute per question.

  1. 00101101 bin → dec

    32 + 8 + 4 + 1 = 45

  2. 11000000 bin → dec

    128 + 64 = 192

  3. 01111111 bin → dec

    64 + 32 + 16 + 8 + 4 + 2 + 1 = 127. (The largest positive value in a signed byte — worth memorising.)

  4. 42 dec → bin

    32 + 8 + 2 = 42, so 00101010.

  5. 200 dec → bin

    128 + 64 + 8 = 200, so 11001000.

  6. 99 dec → bin

    64 + 32 + 2 + 1 = 99, so 01100011.

  7. 11010110 bin → hex

    Split into nibbles: 1101 = 13 = D, 0110 = 6. Answer: 0xD6.

  8. 00101111 bin → hex

    0010 = 2, 1111 = F. Answer: 0x2F.

  9. 0x9C hex → bin

    91001, C (12) → 1100. Answer: 10011100.

  10. 0xB0 hex → bin

    B (11) → 1011, 00000. Answer: 10110000.

  11. 255 dec → hex

    Max unsigned byte → all 1s → all-F per nibble → 0xFF.

  12. 100 dec → hex

    Easiest via binary: 64 + 32 + 4 = 01100100 → split → 0110 (6), 0100 (4) → 0x64. (Yes, 100 in decimal is 0x64 in hex — a useful number to know.)

  13. 16 dec → hex

    0x10. This one trips people up — decimal 16 looks like hex "ten" but it's hex "one-zero", which means "I've rolled over once". The first base anchor from Section 1.

  14. 0x1F hex → dec

    1 × 16 + 15 = 31.

  15. 0xA0 hex → dec

    10 × 16 + 0 = 160.

5. New Lens: The Doubling Trick ~3 min

Place-value addition (the way you've been doing binary→decimal) works, but there's a faster trick that scales to any length of binary, no place-value memorising required. It's called double-and-add:

  1. Start with a running total of 0.
  2. Read the binary number left to right. For each bit: double the running total, then add the bit (0 or 1).
  3. The last value you get is the decimal answer.

Walk through 10110:

BitDoubled total+ bitRunning
10 × 2 = 0+ 11
01 × 2 = 2+ 02
12 × 2 = 4+ 15
15 × 2 = 10+ 111
011 × 2 = 22+ 022

So 10110 = 22. Check: 16 + 4 + 2 = 22 ✅

Why this is the better tool past 8 bits. For a 16- or 32-bit number, place values get unwieldy fast. The doubling trick stays the same: one easy double-then-add per bit. It also moves at the rhythm of the digits, which suits muscle memory.

🎯 Convert using the doubling trick

  1. 1101 bin → dec

    0 → 0+1=1 → 2+1=3 → 6+0=6 → 12+1=13.

  2. 101010 bin → dec

    0→1→2→5→10→21→42.

  3. 11110000 bin → dec

    0→1→3→7→15→30→60→120→240. (Notice — same value as 0xF0.)

6. Drill Block B — Comparing Across Bases ~5 min

🎯 Which is bigger, smaller, or equal?

Convert everything mentally to the same base before comparing. There's a sneaky equal-pair in there.

  1. Which is bigger: 0b10110000 or 0xA8?

    10110000 = 128+32+16 = 176. 0xA8 = 10×16 + 8 = 168. The binary one (176).

  2. Sort smallest → largest: 0x40, 0b01000001, 65

    0x40 = 64. 0b01000001 = 65. 65 = 65. So order is 0x40 (64) < 0b01000001 = 65 — the last two are equal.

  3. Find all the equal values: 17, 0b00010001, 0x11, 0b10001

    Every single one is 17 in disguise. 0x11 = 16 + 1 = 17. 0b10001 and 0b00010001 are the same number with different leading zeros.

  4. Which is the only even value? 0b00010101, 0x13, 17, 0x22

    Check each one's last bit (or last hex digit's parity): 0b00010101 ends in 1 → odd (21). 0x13 = 19 → odd. 17 → odd. 0x22 = 34 → even. Trick to remember: the rightmost binary bit is the parity bit for any base.

  5. What comes next after 0xFF in hex?

    0x100 (which is 256 in decimal). FF means "every digit maxed in this number of digits" — adding 1 forces a new digit, exactly like 99 → 100 in decimal.

7. Hex in the Wild — Colour Speed Round ~4 min

Every CSS colour is a 24-bit number written in hex: #RRGGBB — two hex digits per channel, each going 00 to FF (0 to 255). Without converting, you can read them at a glance once you build the reflex.

🎯 Predict before you reveal

  1. Which is "more red": #FF3300 or #AA3300?
    #FF3300
    #AA3300

    #FF3300 — its red channel is 0xFF (255), vs 0xAA (170). The other channels are identical, so red wins outright.

  2. What colour is #00FF00?
    #00FF00

    Red = 0, Green = max, Blue = 0 → pure green.

  3. Which is darker: #404040 or #C0C0C0?
    #404040
    #C0C0C0

    #404040. All three channels equal = a shade of grey; smaller numbers = darker. 0x40 = 64 is much darker than 0xC0 = 192.

  4. What colour is #FFFF00?
    #FFFF00

    Red max + Green max + Blue zero = yellow. (Useful: red + green = yellow in additive light, not paint mixing.)

  5. Translate the lesson-header purple #6D28D9 into R / G / B decimal values.
    #6D28D9

    Red 0x6D = 6×16 + 13 = 109. Green 0x28 = 2×16 + 8 = 40. Blue 0xD9 = 13×16 + 9 = 217. So mostly blue with a kick of red → blue-purple.

8. Two's Complement — Quick Drills ~6 min

One-line recap: to get the negative version of a binary number, flip every bit, then add 1. Leftmost bit = 1 means negative.

🎯 Drill — assume 8-bit signed throughout

  1. Write −3 in 8-bit two's complement.

    +3 = 00000011 → flip → 11111100 → +1 → 11111101.

  2. Write −10 in 8-bit two's complement.

    +10 = 00001010 → flip → 11110101 → +1 → 11110110.

  3. What signed decimal is 10000001?

    Sign bit is 1 → negative. Flip & add 1 to read magnitude: flip 1000000101111110 → +1 → 01111111 = 127. So the original is −127.

  4. What is the range of an 8-bit signed integer?

    −128 to +127. Asymmetric because zero takes one of the "positive" slots, so negatives get one extra at the low end.

  5. The byte 11111111 — what is it unsigned vs signed?

    Unsigned: 255. Signed: −1. Same eight bits, two completely different values depending on the data type. The interpretation is everything.

  6. Stretch: you add 1 to 01111111 (signed). What happens?

    Binary addition gives 10000000 — which signed reads as −128. The number wrapped from largest positive to smallest negative. This is the classic "integer overflow" bug; it's the same mechanism that famously sent Pac-Man's level 256 into chaos and made the original Gandhi in Civilization absurdly aggressive.

9. Float Gotcha — Mini Quiz ~3 min

A 32-bit single-precision float is split into three chunks — sign, exponent, mantissa. You don't need to encode them by hand. What matters: floats are approximations. Some decimals can't be stored exactly.

Sign1 bit
Exponent8 bits
Mantissa23 bits

🎯 Three fast questions

  1. In Python, does 0.1 + 0.2 == 0.3 return True or False?

    False. The actual sum is 0.30000000000000004 because 0.1 and 0.2 cannot be stored exactly in binary.

  2. Why is 0.1 inexact in binary, when it looks fine in decimal?

    Because 1/10 has no finite representation in base 2 (the binary expansion repeats forever, like 1/3 = 0.333… in decimal). The float just stores the closest pattern its 23 mantissa bits can hold, leaving a tiny error.

  3. You're storing prices in dollars and cents ($19.99). Float or integer-cents?

    Integer cents (1999). Float arithmetic loses cents to rounding error — disastrous for money. Store as the smallest unit, divide by 100 only when displaying.

10. Wrap-Up & Homework ~2 min

The one mental shift to keep

A value isn't binary or decimal or hex — it just is. Each base is a costume. Check the costume before you read.

Homework — Exam-style mixed set (do all 5)

No bias to one direction — write each one out by hand, then check.

  1. Convert 0xC4 to decimal and to binary.

    Decimal: 12×16 + 4 = 196. Binary: C → 1100, 4 → 010011000100.

  2. Convert 173 to binary and to hex.

    173 = 128 + 32 + 8 + 4 + 1 → 10101101. Split for hex: 1010 = A, 1101 = D → 0xAD.

  3. What is −20 in 8-bit two's complement?

    +20 = 00010100 → flip → 11101011 → +1 → 11101100.

  4. Which is bigger: 0b11001100 or 0xCD?

    0b11001100 = 204. 0xCD = 12×16 + 13 = 205. 0xCD wins by one.

  5. The CSS colour #3366FF — is it more red, more green, or more blue? Give the dominant channel in decimal.

    R = 0x33 = 51, G = 0x66 = 102, B = 0xFF = 255. Mostly blue, with G at half and R at a quarter. Result: classic web blue.

If you can do these 5 in 8 minutes with no calculator, you're exam-ready. Whatever felt slow — that's the conversion direction worth drilling again before next lesson.