3.1.2 · D3Boolean Algebra & Logic Gates

Worked examples — Hexadecimal and octal representation

2,547 words12 min readBack to topic

The scenario matrix

Before solving anything, let's list every kind of conversion problem this topic can hand you. Think of it as a checklist — each worked example below is stamped with the cell it fills.

# Case class What makes it tricky Example that covers it
A Binary → hex, length is a multiple of 4 clean chop, no padding Ex 1
B Binary → hex/oct, length not a multiple of the group size must pad the left with zeros Ex 2
C Hex/octal → binary → decimal expand digits, watch letter digits A–F Ex 3
D Decimal → base by repeated division remainders read bottom-up Ex 4
E Hex ↔ octal (different group sizes) must route through binary Ex 5
F Degenerate / zero-ish inputs value 0, a lone digit, leading zeros Ex 6
G Limiting / boundary value the largest value a byte can hold Ex 7
H Real-world word problem translate a story into a conversion Ex 8
I Exam-style twist "10 in base b", or a mixed-up base claim to debunk Ex 9

We'll walk them in order. Grab the group-size fact once and reuse it everywhere:

The figure above is your ruler for every example: the same 8-bit byte sliced two ways — into 4-bit slices (hex) and 3-bit slices (octal). Notice the octal slicing spills past the left edge, forcing a pad. That spill is the source of half the mistakes on this page.


Cell A — clean chop, no padding


Cell B — length not a multiple of the group size (padding)


Cell C — hex/octal → decimal via expansion (letter digits live here)


Cell D — decimal → base by repeated division

The figure shows the division ladder: read the remainder column upward to build the answer.


Cell E — hex ↔ octal, routed through binary


Cell F — degenerate and zero-ish inputs


Cell G — the boundary value (biggest a byte holds)


Cell H — a real-world word problem


Cell I — the exam-style twist


Recall Quick self-test — cover the answers

Which side do you pad when a bit-string is too short for its group? ::: The left (high-order zeros are free; right-padding doubles the value). in octal? ::: . Why can't you convert hex→octal by swapping digits directly? ::: 4-bit and 3-bit boundaries only re-align every 12 bits; route through binary. Largest 8-bit value in hex / decimal / octal? ::: . Is a valid number? ::: No — octal digits are , and is out of range.


Connections