3.1.2 · D2Boolean Algebra & Logic Gates

Visual walkthrough — Hexadecimal and octal representation

2,229 words10 min readBack to topic

Step 1 — What a "bit" even is, and why we line them up in a row

WHAT. A bit is one thing that can only be in two states. Picture a light bulb: it is either off (we call that ) or on (we call that ). Nothing in between. That is the whole idea of binary — base means "two possible digit values, and ."

WHY. Computers are made of switches, and a switch is naturally a two-state thing. So the machine's most honest language is a row of bulbs. But a long row of bulbs is exhausting for a human to read — that is the problem the whole page is about to solve.

PICTURE. Below, a row of 8 bulbs. Dark bulb = , bright bulb = . This exact 8-bulb pattern (our running example ) is the star of every remaining figure.

Figure — Hexadecimal and octal representation

Step 2 — Place value: why the RIGHT end is special

WHAT. Every bulb carries a weight, and the weights are not equal. Reading from the right, the weights are — each step to the left doubles. The tiny raised number is the exponent: means "one" (nothing doubled yet), means "two", means "four", and so on.

The value of the whole row is the positional sum:

Let me name every piece right where it sits:

  • — the digit ( or ) sitting in position (bulb dark or bright).
  • — the position, counted from the right starting at .
  • — the weight of that position; the base raised to the position number.
  • — the "" symbol is just shorthand for "add up all of these, for every position ." It is not new maths; it is a lazy way to write

WHY and not something else? Because each new bulb to the left must be able to represent everything the bulbs to its right can already reach, plus one more. The bulbs to the right of position can count from up to ; so the next bulb has to be worth exactly to continue without gaps or overlaps. That is the deep reason the weights double.

PICTURE. Each bulb labelled with its weight . Notice the arrow: weights grow leftward, so the anchor — the "s place", — is on the right. Remember this; it decides which side we group from.

Figure — Hexadecimal and octal representation
Recall Why does grouping have to start from the right?

Because place value is anchored at on the right ::: any clean grouping must respect that anchor, or the block weights won't line up as powers of the base.


Step 3 — The magic coincidence: 4 bits fill exactly one hex digit

WHAT. Take 4 bulbs in a row. How many different patterns can 4 bulbs make? Each bulb doubles the count: patterns, from up to . And is exactly the number of symbols hexadecimal (base 16) needs: .

WHY this matters. A one-to-one matching. There are four-bit patterns and hex digits — no pattern is left out, no hex digit is unused. So one hex digit is a nickname for exactly one group of 4 bits. No arithmetic, no leftovers.

The hex letters (introduced in the parent) fill the gap above :

PICTURE. All 16 four-bit patterns as tiny bulb-rows, each paired with its single hex nickname. This is the whole translation table.

Figure — Hexadecimal and octal representation

Step 4 — Cutting the byte into hex: watch the groups form

WHAT. Our running byte is . We slide a knife in from the right, cutting every 4 bulbs:

Then we look up each 4-bulb group in the Step-3 table:

  • right group : value , so digit .
  • left group : value .

Reading the groups left-to-right (same order they sit) gives the hex number:

WHY the knife enters from the right. From Step 2, weights are anchored at the right. Each 4-bit block, starting at the right, occupies weights , then , and so on. Those block boundaries land exactly on multiples of — which is precisely why each block becomes a clean power of . Cut from the left instead and the first block would straddle weights like but the last would be a stub at of the wrong size — the powers stop lining up.

PICTURE. The byte with a vertical cut line dropping in from the right, each group boxed and tagged with its hex nickname.

Figure — Hexadecimal and octal representation

Step 5 — Same byte, octal knife: groups of 3

WHAT. Octal is base 8, and , so an octal digit is a nickname for exactly 3 bits ( patterns, digits ). Our byte has bits, and is not a multiple of — so before cutting we pad the left with a zero up to bits (a leading zero never changes the value, it is just a dark bulb worth nothing):

WHY pad on the LEFT specifically. Same anchor logic as Step 4: the knife must enter from the right so blocks align on multiples of . The right end must stay fixed at ; so any spare space to reach a multiple of 3 has to be added on the left, where a costs nothing.

PICTURE. The byte with one pad-bulb (drawn faint) added on the left, then three cuts, each group tagged with its octal digit.

Figure — Hexadecimal and octal representation

Step 6 — Why hex and octal can't talk directly (the degenerate case)

WHAT. It is tempting to convert hex octal by swapping groups directly. You cannot, because -bit groups and -bit groups do not line up on the same boundaries. Watch :

Now re-cut that same bit string into 3s from the right (pad left to 6 bits, dropping the leading pair which is all zero after regroup):

WHY binary is the mandatory middle-man. Binary is the finest grid — every hex block and every octal block is built from single bits. So both align with binary, but their block sizes ( vs ) never align with each other. Binary is the common ground they must both pass through.

PICTURE. The same bit-string shown twice: top ruler cuts it into 4s (hex), bottom ruler into 3s (octal). The cut lines land at different places — that mismatch is the reason.

Figure — Hexadecimal and octal representation

Step 7 — The other degenerate cases: zero, and a length that's already a multiple

WHAT.

  • All bulbs off (): every group is (hex) and (octal). So the byte is and . No surprises — but you must not drop to a single if a fixed width is expected.
  • Length already a multiple of the group size: e.g. (4 bits) needs no padding for hex — it is exactly one group, . For octal though, pads to . Padding is only about reaching the next multiple; when you're already there, skip it.

WHY show these. These are the cases where beginners either over-pad (adding a whole useless group) or under-pad (leaving a stub group that has fewer bits than the base needs). The rule is exact: pad the left with the fewest zeros needed to make the bit count a multiple of the group size (4 for hex, 3 for octal), then never again.

PICTURE. Two mini-rows: the all-off byte, and shown once as a single hex group and once padded into two octal groups.

Figure — Hexadecimal and octal representation

The one-picture summary

Everything above collapses into a single diagram: one binary byte in the middle, a 4-bit ruler cutting it upward into hex, a 3-bit ruler cutting it downward into octal, both knives entering from the right, pad-bulbs drawn faint on the left, and the decimal value hanging off to the side as the invariant nobody's allowed to change.

Figure — Hexadecimal and octal representation
Recall Feynman retelling — say it like you'd tell a friend

A byte is a row of 8 light bulbs, and the rightmost bulb is the "ones" bulb — weights double as you walk left. Long rows are hard to read, so we give nicknames to chunks of bulbs. Here's the lucky thing: 4 bulbs make exactly 16 patterns, and hex has exactly 16 symbols, so 4 bulbs = 1 hex nickname with nothing wasted. Octal has 8 symbols and 3 bulbs make exactly 8 patterns, so 3 bulbs = 1 octal nickname. To translate, I slide a knife in from the right (because the "ones" anchor lives there) and cut every 4 bulbs for hex or every 3 for octal, padding the left with dark bulbs if I run short. Hex and octal can't chat directly — 4s and 3s never cut at the same place — so I always route through the raw bulbs. And no matter how I nickname it, the underlying number ( for our byte) never budges: I only changed its outfit, never its identity.


Quick recall

Why is the group size 4 for hex and 3 for octal?
Because (exponent 4) and (exponent 3); the exponent is the number of bits one digit covers.
Which side do you cut the binary from, and why?
From the right, because place value is anchored at on the right; block boundaries then land on clean powers of the base.
Why pad on the left, never the right?
A leading zero is worthless (worth nothing), and the right end must stay fixed at ; the spare space goes on the left.
Convert to hex and octal.
and (both equal ).
Why can't you convert hex→octal by swapping groups?
4-bit and 3-bit boundaries never coincide; route through binary, the common finest grid.
What is in decimal?
.

Connections