Exercises — Hexadecimal and octal representation
Before we start, one shared picture of the two group sizes we lean on the whole page:

Level 1 — Recognition
L1.1
What decimal value does the hex digit stand for? And ?
Recall Solution
Hex borrows letters once it runs out of –: . So and .
L1.2
Fill in: in base , the digit string "" always equals ?. What is , , ?
Recall Solution
"" means . So it equals the base itself. , , .
L1.3
Which of these are legal octal numbers? .
Recall Solution
Octal digits run – only. A digit is illegal. Legal: (4,7 both ≤7) and . Illegal: (has an 8), (has an 8).
Level 2 — Application
L2.1
Convert to decimal.
Recall Solution
Two hex digits → place values and . And .
L2.2
Convert to decimal.
Recall Solution
Three octal digits → place values .
L2.3
Convert to hex using repeated division. (It should agree with L2.2 via binary later.)
Recall Solution
Divide by 16, keep remainders. Why: the remainder of is exactly the last digit , because every higher term is a multiple of . Read remainders bottom→top (first remainder is the place, so it goes rightmost): . Check: . ✓
L2.4
Convert to hex, then to octal — without any arithmetic, using grouping.

Recall Solution
Hex — group into 4s from the right: . , and . So . Octal — group into 3s from the right, padding the leftmost group: . So . Sanity via decimal: ; and ✓, ✓.
Level 3 — Analysis
L3.1
A student converts to octal by grouping from the left: . Is that right? If not, produce the correct answer and explain why the left-grouping happened to look plausible.
Recall Solution
Here has exactly bits, a clean multiple of , so left and right grouping give the same split → . The answer is actually correct (; and ✓). The lesson: left-grouping is silently equivalent only when the bit-count is already a multiple of the group size. The trap bites the moment the count isn't a multiple of 3 (or 4) — then the padding must go on the left, which is impossible if you started chopping there. So "it worked once" is a false friend.
L3.2
Convert to octal. You are not allowed to go hex→octal directly. Explain in one line why not.
Recall Solution
Why not direct: hex groups are 4 bits, octal groups are 3 bits; and share no common alignment, so there is no digit-by-digit hex↔octal map. Binary is the common middle-man (both align to it). Expand each hex digit to 4 bits: , → . Regroup into 3s from the right: . So . Check: ; ✓.
L3.3
Without full conversion, decide: is bigger, smaller, or equal to ? Justify by bit-width, not by computing decimals.
Recall Solution
= two hex digits = bits, all ones (), so . : → , which is also ones (leading zero drops). Both are , so they are equal — both are .
Level 4 — Synthesis
L4.1
An 8-bit register holds the two's-complement value . Write that byte in binary, then in hex. (You may use the rule from Two's complement and signed numbers: for an 8-bit negative value, take and write that in binary.)
Recall Solution
Step — why : in 8-bit two's complement, the negative number is stored as the unsigned pattern (because wraps around). Here . Convert to binary: . Group into 4s from the right: → . So in an 8-bit register is . Check: , and ✓.
L4.2
You want a bit-mask (see Bitwise operations) that keeps only bits (the low nibble) of a byte and clears the top four. Give the mask in binary and in hex, and explain why hex makes it obvious.
Recall Solution
"Keep low 4, clear top 4" means the mask has s in positions – and s in –: .
Group into 4s: → (often written 0x0F).
Why hex is obvious: each hex digit is one nibble. A digit of = "all four bits on", a digit of = "all four off". So a nibble-aligned mask reads straight off the hex: 0x0F literally spells "off-nibble, on-nibble."
L4.3
A memory address is given as . How many bits does it need at minimum, and what is it in octal?
Recall Solution
Three hex digits × 4 bits = up to bits. Expand: → . Drop leading zeros for the minimum bit count: = significant bits (the top bit is at position 8, so bits –, i.e. 9 bits minimum). Octal — regroup the full 12-bit string into 3s from the right: = , i.e. . Check: ; ✓.
Level 5 — Mastery
L5.1
Invent-the-rule: to convert a number from base straight to base without going through decimal, how many base-4 digits equal one hex digit, and why? Convert to hex using your rule.
Recall Solution
Derive the group size: so one base-4 digit = 2 bits; so one hex digit = 4 bits. Thus 2 base-4 digits = 1 hex digit (because bits). Groups align because both are powers of — the same "middle-man binary" idea, now with the friendlier fact that is itself a power of two. Expand each base-4 digit to 2 bits (): . Group into 4s from the right: → . Check: ; ✓.
L5.2
A byte is written . Rotate its 8 bits left by 2 (bits that fall off the left re-enter on the right — a rotate, not a shift). Give the result in hex.
Recall Solution
: → .
Rotate left by 2: take the top 2 bits 01 off the left and append them on the right. The middle bits 011100 shift up.
.
Regroup: → .
Check by value: . Rotate-left-2 of an 8-bit value ✓.
L5.3
Prove that any number that is a power of two, say , needs exactly one nonzero hex digit only when is a multiple of ; otherwise it spans two hex digits. Illustrate with .
Recall Solution
A power of two in binary is a single followed by zeros. When we group into 4s from the right, that lone lands at bit position , i.e. in group number , at offset inside it.
- If , the sits at the bottom of a group → that group is , and it's a single nonzero hex digit (). Example: , leading digit .
- If , the sits higher inside the group, giving that group the value () — still one nonzero hex digit, e.g. . Let's verify : binary is then ten s = (11 bits). Group into 4s from the right: pad left → = . Here , , so the top hex digit is — a single nonzero hex digit (), just not the digit . The claim as stated ("digit only when is a multiple of 4") holds: only gives leading digit exactly 1.
Recall One-line recap of every answer
L1.1 C=12, E=14 · L1.2 "10"=b · L1.3 legal · L2.1 · L2.2 · L2.3 · L2.4 · L3.1 (equal by luck) · L3.2 · L3.3 equal () · L4.1 · L4.2 0x0F · L4.3 9 bits, · L5.1 · L5.2 · L5.3 .
Connections
- Hexadecimal and octal representation — the parent topic these exercises drill.
- Binary number system · Positional number systems and place value — the machinery behind every conversion.
- Two's complement and signed numbers — used in L4.1.
- Bitwise operations — used in L4.2 and L5.2.
- Memory addresses and byte addressing — L4.3.
- Boolean Algebra & Logic Gates