You know the rules. Today we drill them until they're instant.
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.
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.
| Decimal | Binary | Hex | What to notice |
|---|---|---|---|
| 0 | 0000 0000 | 00 | all zero in every base — easy anchor |
| 15 | 0000 1111 | 0F | one full nibble of 1s — biggest single hex digit |
| 16 | 0001 0000 | 10 | Hex "10" is decimal 16, not 10. "10" means "I rolled over". Each base rolls at a different number. |
| 42 | 0010 1010 | 2A | notice how binary's two nibbles map exactly to the two hex digits |
| 128 | 1000 0000 | 80 | a single high bit — that's the sign bit position in a signed byte |
| 255 | 1111 1111 | FF | every bit on — biggest value an unsigned byte can hold |
| 256 | 1 0000 0000 | 100 | one 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.
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:
| Dec | Bin | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
| 16 | 1 0000 | 10 |
| 17 | 1 0001 | 11 |
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.
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.
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.
Each tag tells you the input base. Aim for under 1 minute per question.
32 + 8 + 4 + 1 = 45
128 + 64 = 192
64 + 32 + 16 + 8 + 4 + 2 + 1 = 127. (The largest positive value in a signed byte — worth memorising.)
32 + 8 + 2 = 42, so 00101010.
128 + 64 + 8 = 200, so 11001000.
64 + 32 + 2 + 1 = 99, so 01100011.
Split into nibbles: 1101 = 13 = D, 0110 = 6. Answer: 0xD6.
0010 = 2, 1111 = F. Answer: 0x2F.
9 → 1001, C (12) → 1100. Answer: 10011100.
B (11) → 1011, 0 → 0000. Answer: 10110000.
Max unsigned byte → all 1s → all-F per nibble → 0xFF.
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.)
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.
1 × 16 + 15 = 31.
10 × 16 + 0 = 160.
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:
Walk through 10110:
| Bit | Doubled total | + bit | Running |
|---|---|---|---|
| 1 | 0 × 2 = 0 | + 1 | 1 |
| 0 | 1 × 2 = 2 | + 0 | 2 |
| 1 | 2 × 2 = 4 | + 1 | 5 |
| 1 | 5 × 2 = 10 | + 1 | 11 |
| 0 | 11 × 2 = 22 | + 0 | 22 |
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.
0 → 0+1=1 → 2+1=3 → 6+0=6 → 12+1=13.
0→1→2→5→10→21→42.
0→1→3→7→15→30→60→120→240. (Notice — same value as 0xF0.)
Convert everything mentally to the same base before comparing. There's a sneaky equal-pair in there.
0b10110000 or 0xA8?10110000 = 128+32+16 = 176. 0xA8 = 10×16 + 8 = 168. The binary one (176).
0x40, 0b01000001, 650x40 = 64. 0b01000001 = 65. 65 = 65. So order is 0x40 (64) < 0b01000001 = 65 — the last two are equal.
17, 0b00010001, 0x11, 0b10001Every single one is 17 in disguise. 0x11 = 16 + 1 = 17. 0b10001 and 0b00010001 are the same number with different leading zeros.
0b00010101, 0x13, 17, 0x22Check 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.
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.
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.
#FF3300 or #AA3300?#FF3300 — its red channel is 0xFF (255), vs 0xAA (170). The other channels are identical, so red wins outright.
#00FF00?Red = 0, Green = max, Blue = 0 → pure green.
#404040 or #C0C0C0?#404040. All three channels equal = a shade of grey; smaller numbers = darker. 0x40 = 64 is much darker than 0xC0 = 192.
#FFFF00?Red max + Green max + Blue zero = yellow. (Useful: red + green = yellow in additive light, not paint mixing.)
#6D28D9 into R / G / B decimal values.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.
One-line recap: to get the negative version of a binary number, flip every bit, then add 1. Leftmost bit = 1 means negative.
+3 = 00000011 → flip → 11111100 → +1 → 11111101.
+10 = 00001010 → flip → 11110101 → +1 → 11110110.
10000001?Sign bit is 1 → negative. Flip & add 1 to read magnitude: flip 10000001 → 01111110 → +1 → 01111111 = 127. So the original is −127.
−128 to +127. Asymmetric because zero takes one of the "positive" slots, so negatives get one extra at the low end.
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.
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.
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.
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.
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.
Integer cents (1999). Float arithmetic loses cents to rounding error — disastrous for money. Store as the smallest unit, divide by 100 only when displaying.
A value isn't binary or decimal or hex — it just is. Each base is a costume. Check the costume before you read.
No bias to one direction — write each one out by hand, then check.
0xC4 to decimal and to binary.Decimal: 12×16 + 4 = 196. Binary: C → 1100, 4 → 0100 → 11000100.
173 to binary and to hex.173 = 128 + 32 + 8 + 4 + 1 → 10101101. Split for hex: 1010 = A, 1101 = D → 0xAD.
+20 = 00010100 → flip → 11101011 → +1 → 11101100.
0b11001100 or 0xCD?0b11001100 = 204. 0xCD = 12×16 + 13 = 205. 0xCD wins by one.
#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.