How to Convert Between Number Bases
All number systems share one underlying idea: positional notation — each digit's contribution depends on its position. The only thing that changes from one system to another is the base, which determines how quickly positional values grow. Converting between any two bases always decomposes into the same two-step process: read the source number's value (using positional notation to convert to decimal), then express that value in the target base (using the repeated-division algorithm). For binary, octal, and hexadecimal, direct bit-grouping shortcuts let you skip the decimal step entirely — making those conversions near-instantaneous.
The Four Standard Number Systems
| System | Base | Digits used | 1 digit represents |
|---|---|---|---|
| Binary | 2 | 0, 1 | 1 bit |
| Octal | 8 | 0–7 | 3 bits (since 2³ = 8) |
| Decimal | 10 | 0–9 | not a power of 2 |
| Hexadecimal | 16 | 0–9, A–F | 4 bits (since 2⁴ = 16) |
Binary is the fundamental language of digital hardware. Octal and hexadecimal are compact shorthand for binary — each octal digit is exactly 3 bits, each hex digit exactly 4 bits. Decimal is what humans naturally use, but it is not a power of 2, so converting to/from decimal always requires arithmetic rather than simple substitution.
The General Two-Step Conversion Method
To convert a number from any base B to any base C, use these two steps:
- Step 1 — Source → Decimal (Positional Notation): multiply each digit by B raised to its position (rightmost = position 0) and sum all products. For hex digits A–F, substitute the values 10–15.
- Step 2 — Decimal → Target (Repeated Division): divide the decimal value by C repeatedly, recording each remainder. Read all remainders from last to first — that sequence is the result in base C.
Worked Example 1 — Convert (374)₈ to Hexadecimal (via Decimal)
Step 1: Convert octal (374)₈ to decimal using positional notation.
Step 2: Convert 252₁₀ to hexadecimal using repeated division by 16.
| Dividend | ÷ 16 | Quotient | Remainder (digit) |
|---|---|---|---|
| 252 | ÷ 16 | 15 | C (12) ← least significant digit |
| 15 | ÷ 16 | 0 | F (15) ← most significant digit |
Shortcut Conversions — Skip the Decimal Step
When both the source and target base are powers of 2 (binary, octal, hex), you can skip the decimal intermediate entirely. These shortcuts work because 2³ = 8 and 2⁴ = 16 — each octal digit is exactly 3 bits, and each hex digit is exactly 4 bits.
| Conversion | Shortcut method | Speed |
|---|---|---|
| Binary → Octal | Group binary into 3-bit chunks from right; each chunk → 1 octal digit | Very fast |
| Binary → Hex | Group binary into 4-bit chunks from right; each chunk → 1 hex digit | Very fast |
| Octal → Binary | Replace each octal digit with its 3-bit binary equivalent | Very fast |
| Hex → Binary | Replace each hex digit with its 4-bit binary equivalent | Very fast |
| Octal ↔ Hex | Go via binary: octal→binary→hex or hex→binary→octal | Fast |
| Any other pair | Two-step via decimal (positional notation + repeated division) | Always works |
Worked Example 2 — Convert (374)₈ to Hexadecimal (Shortcut via Binary)
The same conversion as Example 1 but using the binary shortcut — demonstrating that both methods give the same answer.
Step 1: Expand each octal digit to 3 bits → 3=011, 7=111, 4=100 → binary string 011 111 100.
Step 2: Regroup into 4-bit chunks from right (pad left if needed) → 0 1111 1100 → 0000 1111 1100.
| 4-bit group | 0000 | 1111 | 1100 |
|---|---|---|---|
| Hex digit | 0 (drop) | F | C |
Worked Example 3 — Convert (D7E)₁₆ to Octal
Step 1: Expand each hex digit to 4 bits → D=1101, 7=0111, E=1110 → binary 1101 0111 1110.
Step 2: The 12-bit string is already a multiple of 3, so regroup directly into 3-bit chunks: 110 | 101 | 111 | 110.
| 3-bit group | 110 | 101 | 111 | 110 |
|---|---|---|---|---|
| Octal digit | 6 | 5 | 7 | 6 |
Summary — Which Method to Choose
| From / To | Binary | Octal | Decimal | Hex |
|---|---|---|---|---|
| Binary | — | 3-bit groups | Positional sum | 4-bit groups |
| Octal | 3-bit expand | — | Positional sum | Via binary |
| Decimal | Div ÷ 2 | Div ÷ 8 | — | Div ÷ 16 |
| Hex | 4-bit expand | Via binary | Positional sum | — |
- Base N Converter — Convert between any two of the four standard number bases
- Base N Converter Formula — Positional notation and division algorithm with worked examples
Frequently Asked Questions
Is there a direct method to convert between any two bases without going through decimal?
For binary, octal, and hex — yes. The bit-grouping shortcuts (3-bit for octal, 4-bit for hex) let you convert directly without any arithmetic. For conversions involving decimal or other bases, the two-step via-decimal method is the universal approach. It always works, regardless of which two bases you're converting between.
Why are octal and hex more useful than decimal for working with binary?
Because they are both powers of 2 (8=2³, 16=2⁴), each octal or hex digit maps to an exact number of binary bits. This makes it trivial to read, write, and spot patterns in binary data without lengthy arithmetic. Decimal has no such relationship with binary, so decimal conversions always require actual computation.
How do bases above 16 work?
For base 17–36, the convention is to continue using letters: G=16, H=17, …, Z=35. Base-32 (using A–V for 10–31) and base-36 (using A–Z for 10–35) appear in URL shorteners and identifiers. Base-64 uses A–Z, a–z, 0–9, +, / and is widely used for encoding binary data in email attachments and JSON Web Tokens.
What is a 'radix' and is it the same as a 'base'?
Yes — radix and base are synonyms in mathematics and computer science. Both refer to the number of unique digits a number system uses. Binary has radix 2, octal radix 8, decimal radix 10, and hexadecimal radix 16. The word 'radix' comes from Latin (meaning root) and appears in technical contexts; 'base' is the more colloquial term.