Intuition What this page is for
The parent note taught you the rules .
This page throws every kind of question at you — small numbers, big numbers, the number
zero, powers of two, "how many bits do I need?", a real-world storage problem, and an exam trap.
If you can do all of these, no binary question can surprise you.
Every binary/byte question is really one of these case classes . We work at least one example of each.
Cell
Case class
What makes it tricky
Covered by
A
Small binary → decimal
line up column weights
Ex 1
B
Full byte → decimal (all 1s)
the max value 255
Ex 2
C
Zero / degenerate input
0 and leading zeros
Ex 3
D
Decimal → binary (odd)
remainders bottom-up
Ex 4
E
Decimal → binary (exact power of 2)
a single lone 1
Ex 5
F
"How many bits fit this number?"
2 n > N , off-by-one
Ex 6
G
Real-world storage word problem
KiB vs kB units
Ex 7
H
Exam twist: max-value trap
2 n vs 2 n − 1
Ex 8
Keep that picture in your head — each bit is a switch, each column doubles . Every example below is just this ruler used forwards or backwards.
110 1 2 to decimal
Forecast: cover the answer. The bits are on at columns worth 8 , 4 , _ , 1 . Add them in your head before reading on.
Write the column weights under the bits.
1 8 1 4 0 2 1 1
Why this step? Lining weights under bits stops position-miscounting — the #1 error.
Keep only the columns with a 1 . Columns 8 , 4 , 1 are ON; the 2 -column is OFF so it contributes 0 .
Why this step? A 0 digit means 0 × weight = 0 , so it can be skipped.
Add: 8 + 4 + 0 + 1 = 13 .
Verify: rebuild it — is 13 really 1101 ? 13 − 8 = 5 , 5 − 4 = 1 , 1 − 1 = 0 . Used the 8 , 4 , 1 columns → 1101 . ✓
1111111 1 2 to decimal
Forecast: eight ones. Guess the total. (Nearly everyone guesses 256 — is that right?)
Weights of a byte (right→left): 1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 .
Why? Base is 2 , so each column doubles; eight columns give these eight numbers.
All bits ON, so add them all:
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
Why this step? Every switch contributes its full weight when it is 1 .
Verify (a doubling shortcut): the sum 1 + 2 + 4 + ⋯ + 128 of powers of two up to 128 equals 256 − 1 = 255 . This is why the max value of a byte is 255 , not 256 — there are 256 patterns , running 0 … 255 . ✓
0 2 and 0010 1 2 to decimal
Forecast: does a leading zero change anything? Guess both answers.
0 2 : the only column is OFF → value 0 .
Why worth showing? 0 is a valid value (it's why unsigned range starts at 0 ). Zero patterns count.
0010 1 2 : line up weights.
0 16 0 8 1 4 0 2 1 1
ON columns: 4 and 1 → 4 + 1 = 5 .
Why this step? The two leading zeros add 0 ⋅ 16 + 0 ⋅ 8 = 0 ; leading zeros never change a number's value — just like 007 = 7 in decimal.
Verify: 0010 1 2 = 5 and 10 1 2 = 5 — same number, padding ignored. ✓
3 7 10 to binary (repeated division by 2)
Forecast: 37 is between 32 and 64 , so it needs a 32 -column → 6 bits. Guess the pattern.
Divide by 2 repeatedly, record each remainder:
step
divide
quotient
remainder (bit)
1
37/2
18
1
2
18/2
9
0
3
9/2
4
1
4
4/2
2
0
5
2/2
1
0
6
1/2
0
1
Why this step? Each division asks "how many pairs, and is one left over?" The remainder is the current lowest bit.
Read remainders bottom → top: 10010 1 2 .
Why bottom-up? The first remainder is the 2 0 (rightmost) bit; the last is the most significant. Read downward and you'd reverse the number.
Verify: 10010 1 2 = 32 + 0 + 0 + 4 + 0 + 1 = 37 . ✓
3 2 10 to binary
Forecast: powers of two are special. Guess how many 1 s appear.
32 = 2 5 . A power of two is a single ON switch at column 2 5 and zeros everywhere below.
Why? 32 is one full group of 2 5 with nothing left over — no smaller columns needed.
So 32 = 1 2 4 … 2 0 00000 = 10000 0 2 (a 1 followed by five zeros).
Why five zeros? Columns 2 0 through 2 4 are all empty.
Verify: count the digits — a 1 then 5 zeros = 6 digits, and 10000 0 2 = 32 . ✓
Pattern to remember: 2 k in binary = a 1 followed by exactly k zeros.
Worked example How many bits are needed to store the decimal number
500 ?
Forecast: we need the smallest n with enough patterns to reach 500 . Guess n .
Set up the condition. With n bits, values run 0 to 2 n − 1 . To hold 500 we need
2 n − 1 ≥ 500 ⟺ 2 n ≥ 501
Why ≥ 501 , not ≥ 500 ? Because 0 eats one pattern; the largest storable value is 2 n − 1 , so we need 2 n at least one above 500 .
Climb the powers of two. 2 8 = 256 < 501 . 2 9 = 512 ≥ 501 . So n = 9 bits.
Why check both? 2 8 fails (max 255 ), 2 9 succeeds (max 511 ) — proving 9 is the smallest that works.
Verify: 9 bits give range 0 … 511 , and 500 ≤ 511 . ✓ Eight bits would top out at 255 < 500 . ✓
Worked example A camera photo is
3 MiB . How many bits is that, and how many such photos fit on a 256 MiB card?
Forecast: "MiB" is the binary megabyte. Guess whether the photo count is a round number.
Convert one photo to bytes. 1 MiB = 2 20 bytes = 1 , 048 , 576 bytes.
3 MiB = 3 × 1 , 048 , 576 = 3 , 145 , 728 bytes
Why 2 20 not 1 0 6 ? MiB is a binary prefix (Mebi = 2 20 ). Using 1 0 6 here would be the SI megabyte (MB) — a different unit.
Convert bytes to bits. 1 byte = 8 bits, so
3 , 145 , 728 × 8 = 25 , 165 , 824 bits .
Why × 8 ? By convention a byte is 8 bits (see the parent byte note).
Photos on the card: 256 MiB ÷ 3 MiB = 256/3 = 85.33 …
Why floor it? You can't store a fraction of a photo, so round down : 85 photos.
Verify: 85 × 3 = 255 MiB ≤ 256 , but 86 × 3 = 258 > 256 won't fit. ✓
Common mistake Silently mixing MiB and MB
If you'd used 1 MB = 1 0 6 bytes, one photo would be 3 , 000 , 000 bytes — a different number.
Fix: binary prefixes (KiB, MiB, GiB) use powers of 2 ; SI prefixes (kB, MB, GB) use powers of 10 . Match the unit to the context (RAM/OS = binary, disk labels = SI).
Worked example An exam claims: "A
4 -bit register can store the value 16 ." True or false, and what is the real maximum?
Forecast: 2 4 = 16 … is 16 actually storable? Decide before reading.
Count patterns. 4 bits → 2 4 = 16 patterns .
Why patterns first? Each of the 4 bits has 2 choices; 2 × 2 × 2 × 2 = 16 .
List the range. Patterns run 0 , 1 , 2 , … , 15 — that's 16 values, but the largest is 15 , i.e. 2 4 − 1 .
Why − 1 ? Because 0 is one of the 16 values, the top of the run is one below the count.
Verdict: the claim is FALSE . Max value in 4 bits is 15 (111 1 2 ), not 16 .
Why this trap works: 2 n (the count ) and 2 n − 1 (the max ) look almost identical, so it's the exam's favourite catch.
Verify: 111 1 2 = 8 + 4 + 2 + 1 = 15 , and there is no 4 -bit pattern above it. ✓
Recall Did every matrix cell get worked?
A small→dec ::: Ex 1 (110 1 2 = 13 )
B all-ones byte ::: Ex 2 (1111111 1 2 = 255 )
C zero / leading zeros ::: Ex 3 (0 = 0 , 0010 1 2 = 5 )
D decimal→binary odd ::: Ex 4 (37 = 10010 1 2 )
E exact power of two ::: Ex 5 (32 = 10000 0 2 )
F bits needed ::: Ex 6 (500 → 9 bits)
G real-world units ::: Ex 7 (3 MiB = 25 , 165 , 824 bits, 85 photos)
H max-value trap ::: Ex 8 (4 bits max = 15 )