Skip to content
BetterDL

Base conversion

Also called: number base conversion, radix conversion, conversion, converting between bases

Rewriting a number from one base into another without changing its value, for example from binary to decimal or from hexadecimal to binary.

Base conversion changes how a number is written, never what it's worth. 13₁₀, 1101₂, 15₈ and D₁₆ are the same amount.

There are three kinds of conversion, each with a standard method:

  1. To decimal, from any base: multiply each digit by its weight and add. See binary to decimal conversion and hex decimal conversion.
  2. From decimal to base b: divide by b over and over and read the remainders from last to first (repeated division). For binary you can also subtract powers of 2 (decimal to binary conversion).
  3. Between binary, octal and hex: no arithmetic at all. One hex digit is 4 bits and one octal digit is 3 bits, so you just regroup (binary hex conversion, binary octal conversion). Hex ↔ octal goes through binary (hex octal conversion).

A habit worth keeping for every conversion: convert back to check. It catches the most common slips, like reading remainders in the wrong order or grouping bits from the wrong end.

1
8
1
4
0
2
1
1

Worked example

Example

52₁₀ to binary, octal and hex

Get the binary first; octal and hex then come from regrouping.

  1. 1.

    Binary: 52 = 32 + 16 + 4, so 110100₂.

  2. 2.

    Octal: group in threes from the right, 110 | 100, giving 64₈. Check: 6 × 8 + 4 = 52.

  3. 3.

    Hex: group in fours from the right, 0011 | 0100, giving 34₁₆. Check: 3 × 16 + 4 = 52.

Common mistakes

  • Converting between hex and octal digit by digit. The groups don't line up.

  • Skipping the check. Converting the answer back takes seconds and catches most errors.

  • Reading repeated-division remainders in the order they were written. The last remainder is the leftmost digit.

Practice Base conversion

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

Learn it step by step

Base conversion is taught in Number Systems.