Number System Conversions: Binary to Octal and Hexadecimal
Binary numbers are used internally by digital computers, but long binary numbers can be difficult for people to read and remember. Octal and hexadecimal provide shorter ways to represent binary values. Since their bases are powers of two, binary numbers can be converted to these systems by grouping bits.
This short note explains how to convert binary numbers into octal and hexadecimal, how to use bit groups, and how to check the result.
Number systems and their bases
A number system is a way of representing numbers using a set of digits or symbols and a base (also called a radix). The base determines how many different digit values are available.
| Number system | Base | Digits or symbols |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0โ7 |
| Decimal | 10 | 0โ9 |
| Hexadecimal | 16 | 0โ9 and AโF |
In hexadecimal, the letters A to F represent the values 10 to 15.
| Hexadecimal digit | Decimal value |
|---|---|
| A | 10 |
| B | 11 |
| C | 12 |
| D | 13 |
| E | 14 |
| F | 15 |
Why binary can be converted directly
Octal and hexadecimal are closely related to binary because:
- (8 = 2^3), so one octal digit represents exactly three binary bits.
- (16 = 2^4), so one hexadecimal digit represents exactly four binary bits.
This relationship makes conversion straightforward. Instead of converting the binary number to decimal first, divide the binary digits into groups and replace each group with its corresponding octal or hexadecimal digit.
Key Idea: Group binary digits from the right-hand side. Use groups of 3 bits for octal and groups of 4 bits for hexadecimal.
Binary to octal conversion
To convert a binary number to octal:
- Start at the rightmost bit and divide the binary number into groups of three bits.
- If the leftmost group has fewer than three bits, add leading zeros to complete it.
- Convert each 3-bit group into its octal value.
- Write the octal digits in the same order as the groups, from left to right.
The added zeros are placed at the beginning of the number, so they do not change its value.
3-bit binary to octal reference
| Binary group | Octal digit |
|---|---|
| 000 | 0 |
| 001 | 1 |
| 010 | 2 |
| 011 | 3 |
| 100 | 4 |
| 101 | 5 |
| 110 | 6 |
| 111 | 7 |
Each possible 3-bit group corresponds to one octal digit.
Example 1: Convert 1101011โ to octalStep 1: Group the bits from the right.
The binary number has seven bits. Make groups of three, starting from the right. Add a leading zero to complete the first group.
1101011โ
001 101 011Step 2: Convert each group.
001represents 1.101represents 5.011represents 3.
Step 3: Write the octal digits in order.
001 101 011
1 5 3Therefore:
[ 1101011_2 = 153_8 ]
Example 2: Convert 101001โ to octalGroup the bits into sets of three from the right:
101 001Convert each group using the reference table:
101= 5001= 1
Therefore:
[ 101001_2 = 51_8 ]
Binary to hexadecimal conversion
To convert a binary number to hexadecimal, use a similar method, but make groups of four bits.
- Start from the rightmost bit and divide the binary number into groups of four.
- Add leading zeros to the leftmost group if it contains fewer than four bits.
- Convert each 4-bit group into its hexadecimal digit.
- Write the hexadecimal digits in the same order as the groups.
A hexadecimal digit can represent any value from 0 to 15. Values 10 to 15 are written using A, B, C, D, E, and F.
4-bit binary to hexadecimal reference
| Binary group | Hexadecimal digit |
|---|---|
| 0000 | 0 |
| 0001 | 1 |
| 0010 | 2 |
| 0011 | 3 |
| 0100 | 4 |
| 0101 | 5 |
| 0110 | 6 |
| 0111 | 7 |
| 1000 | 8 |
| 1001 | 9 |
| 1010 | A |
| 1011 | B |
| 1100 | C |
| 1101 | D |
| 1110 | E |
| 1111 | F |
Step 1: Group the bits from the right into sets of four.
1101 1110Step 2: Convert each group.
1101represents 13, which is D in hexadecimal.1110represents 14, which is E in hexadecimal.
Step 3: Write the hexadecimal digits in order.
Therefore:
[ 11011110_2 = DE_{16} ]
Example 2: Convert 10101โ to hexadecimalThe number has five bits. Group from the right and add leading zeros to complete the leftmost group:
0001 0101Convert the groups:
0001= 10101= 5
Therefore:
[ 10101_2 = 15_{16} ]
Understanding the grouping method
The grouping method works because each group represents one digit in the target number system.
For octal, a group of three bits has a value from 0 to 7. For hexadecimal, a group of four bits has a value from 0 to 15. These are exactly the digit ranges used by the respective number systems.
When converting, do not reverse the groups. Read the converted digits from left to right in the same order as the binary groups.
Quick comparison
| Conversion | Group size | Target digit range |
|---|---|---|
| Binary to octal | 3 bits | 0โ7 |
| Binary to hexadecimal | 4 bits | 0โ9, AโF |
Common mistakes to avoid
- Grouping from the wrong side: Always begin grouping at the rightmost bit.
- Using the wrong group size: Use 3 bits for octal and 4 bits for hexadecimal.
- Forgetting leading zeros: Complete the leftmost group when necessary. Only add zeros to the left, not to the right.
- Reversing the result: Keep the converted digits in the same left-to-right order as their groups.
- Writing hexadecimal values incorrectly: Remember that A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15.
Exam-focused points
Key Idea: Binary-to-octal conversion uses groups of 3 bits because (8=2^3).
Key Idea: Binary-to-hexadecimal conversion uses groups of 4 bits because (16=2^4).
Key Idea: If the leftmost group is incomplete, add leading zeros. These zeros do not change the value of the binary number.
Quick practice
Try converting each binary number without using a decimal conversion step.
| Binary number | Convert to |
|---|---|
| (110_2) | Octal |
| (11001_2) | Octal |
| (111001_2) | Octal |
| (1010_2) | Hexadecimal |
| (11011110_2) | Hexadecimal |
| (10101_2) | Hexadecimal |
Answers
| Binary number | Result |
|---|---|
| (110_2) | (6_8) |
| (11001_2) | (31_8) |
| (111001_2) | (71_8) |
| (1010_2) | (A_{16}) |
| (11011110_2) | (DE_{16}) |
| (10101_2) | (15_{16}) |
Summary
Binary numbers can be converted directly into octal and hexadecimal by grouping bits. For octal, make groups of three bits; for hexadecimal, make groups of four bits. In both cases, start from the right, add leading zeros if needed, convert each group using the corresponding values, and write the results in order. The number's value stays the same; only its representation changes.