Logo
All chapters
Volume II: Digital Logic  ›  Digital Systems & Binary Numbers

Octal & Hexadecimal Numbers

Shorthand for binary: octal packs 3 bits per digit, hex packs 4 bits per digit.

PrevNumber-Base Conversions
NextComplements of Numbers

Description

Bases 8 and 16 used as compact stand-ins for long binary strings. Binary is error-prone to read; one hex digit replaces four bits at a glance. Group binary bits (3 for octal, 4 for hex) from the radix point and map each group to a digit.

  • Hex: split binary into 4-bit groups from the right; map each to 0–9, A–F.
  • Octal: split into 3-bit groups; map each to 0–7.
  • Pad the leftmost group with leading zeros if needed.
  • Modern word sizes (8/16/32/64) are multiples of 4 → clean hex alignment.
  • Two hex digits = one byte, the universal unit of memory.
  • What: Bases 8 and 16 used as compact stand-ins for long binary strings.
  • Why: Binary is error-prone to read; one hex digit replaces four bits at a glance.
  • How: Group binary bits (3 for octal, 4 for hex) from the radix point and map each group to a digit.
  • Where: Memory addresses, color codes (#RRGGBB), machine code, register dumps.
  • When: Anywhere binary values must be displayed or typed by people.

At a glance

What

Bases 8 and 16 used as compact stand-ins for long binary strings.

Why

Binary is error-prone to read; one hex digit replaces four bits at a glance.

How

Group binary bits (3 for octal, 4 for hex) from the radix point and map each group to a digit.

Where

Memory addresses, color codes (#RRGGBB), machine code, register dumps.

When

Anywhere binary values must be displayed or typed by people.

Think of it like…

Like packing loose bits into boxes: hex uses boxes of 4 bits, octal boxes of 3. One box label (a hex/octal digit) stands in for the whole box — shorter to write, same contents.

Grouping rule

  • Hex: split binary into 4-bit groups from the right; map each to 0–9, A–F.
  • Octal: split into 3-bit groups; map each to 0–7.
  • Pad the leftmost group with leading zeros if needed.

Why hex dominates

  • Modern word sizes (8/16/32/64) are multiples of 4 → clean hex alignment.
  • Two hex digits = one byte, the universal unit of memory.

Hex digit map

BinaryHexBinaryHex
0000010008
0001110019
001021010A
001131011B
010041100C
010151101D
011061110E
011171111F

Convert decimal to octal / hex

▶ live simulator
stepvalue ÷ 2quotientremainder
1156 ÷ 2780
278 ÷ 2390
339 ÷ 2191
419 ÷ 291
59 ÷ 241
64 ÷ 220
72 ÷ 210
81 ÷ 201

Read remainders bottom-to-top → 10011100

The 5 Whys

  1. 1

    Why octal/hex? To write binary compactly without losing information.

  2. 2

    Why compactness? Long bit strings are hard to read and easy to mistype.

  3. 3

    Why 3 and 4 bits specifically? 8 = 2³ and 16 = 2⁴, so grouping is exact.

  4. 4

    Why does exact grouping matter? It makes conversion lossless and instant.

  5. 5

    Root cause: choosing a base that is a power of two makes binary↔base mapping a pure regrouping.

Cheat sheet

Working principle

  • Group binary bits (3 for octal, 4 for hex) from the radix point and map each group to a digit.
  • Bases 8 and 16 used as compact stand-ins for long binary strings.

Formulas & Boolean expressions

  • Two hex digits = one byte, the universal unit of memory.

Key facts

  • Hex: split binary into 4-bit groups from the right; map each to 0–9, A–F.
  • Modern word sizes (8/16/32/64) are multiples of 4 → clean hex alignment.

Why it exists

  • Root cause: choosing a base that is a power of two makes binary↔base mapping a pure regrouping.
PrevNumber-Base Conversions
NextComplements of Numbers