Skip to content
BetterDL

Hex–octal conversion

Also called: hex to octal, octal to hex, hexadecimal to octal, octal to hexadecimal

Converting between hexadecimal and octal by going through binary: expand each digit into bits, then regroup the bits in threes or fours from the right.

Hex digits are 4 bits and octal digits are 3 bits, so the digit boundaries don't line up. The reliable route goes through binary:

  1. Expand each digit into its bits: 4 per hex digit, 3 per octal digit.
  2. Regroup the bits from the right: in threes for octal, in fours for hex.
  3. Pad the leftmost group with zeros and read off the new digits.

You could go through decimal instead (convert to decimal, then repeated division), but that needs real arithmetic. The binary route is nothing but lookups (binary hex conversion, binary octal conversion).

What doesn't work is converting digit by digit. A5₁₆ is not "A → 12₈ and 5 → 5₈, so 125₈". That would be 85, but A5₁₆ is 165.

B
16¹
7
16⁰

Worked examples

Example

B7₁₆ to octal

Expand to bits, regroup in threes.

  1. 1.

    B → 1011, 7 → 0111, so the bits are 10110111.

  2. 2.

    Regroup from the right: 10 | 110 | 111, padded to 010 | 110 | 111.

  3. 3.

    010 = 2, 110 = 6, 111 = 7, so 267₈.

  4. 4.

    Check: B7₁₆ = 11 × 16 + 7 = 183, and 267₈ = 2 × 64 + 6 × 8 + 7 = 183.

Example

571₈ to hex

Expand to bits, regroup in fours.

  1. 1.

    5 → 101, 7 → 111, 1 → 001, so the bits are 101111001.

  2. 2.

    Regroup from the right: 1 | 0111 | 1001, padded to 0001 | 0111 | 1001.

  3. 3.

    That's 179₁₆.

  4. 4.

    Check: 571₈ = 320 + 56 + 1 = 377, and 179₁₆ = 256 + 112 + 9 = 377.

Common mistakes

  • Converting digit by digit instead of going through binary.

  • Regrouping from the left after expanding.

  • Dropping a digit's leading zeros while expanding: octal 1 is 001.

Practice Hex–octal conversion

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Hex–octal conversion is taught in Number Systems.