Number System Conversions: Hexadecimal to Binary and Octal
A number can be represented in different number systems without changing its actual value. In digital systems, hexadecimal is often used as a compact way to write binary values. Since octal and hexadecimal are both related to binary, conversions between them can be performed by replacing digits or grouping binary digits.
This note explains how to convert hexadecimal to binary and hexadecimal to octal, with worked examples and key points for revision.
1. Hexadecimal Number System
The hexadecimal number system is a base-16 number system. It uses sixteen symbols:
- Digits
0to9represent values zero to nine. - Letters
AtoFrepresent values ten to fifteen.
| Hexadecimal digit | Decimal value | 4-bit binary |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 3 | 3 | 0011 |
| 4 | 4 | 0100 |
| 5 | 5 | 0101 |
| 6 | 6 | 0110 |
| 7 | 7 | 0111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
Each hexadecimal digit corresponds exactly to four binary bits because (16 = 2^4). This makes hexadecimal-to-binary conversion direct.
2. Converting Hexadecimal to Binary
To convert a hexadecimal number to binary, replace each hexadecimal digit with its equivalent 4-bit binary value. Keep the digits in the same order.
Method
- Separate the hexadecimal number into individual digits.
- Find the 4-bit binary equivalent of each digit using the reference table.
- Write the binary groups in the original order.
- Join the groups to form the binary number.
There is no need to add extra leading zeros to a hexadecimal digit's binary equivalent: every digit is represented by exactly four bits.
Example 1: Convert (3A_{16}) to binaryConvert each hexadecimal digit separately:
| Hexadecimal digit | 4-bit binary |
|---|---|
3 | 0011 |
A | 1010 |
Join the groups in the same order:
0011 + 1010 = 00111010
Therefore,
[ 3A_{16} = 00111010_2 ]
Example 2: Convert (7F_{16}) to binary| Hexadecimal digit | 4-bit binary |
|---|---|
7 | 0111 |
F | 1111 |
Join the groups:
0111 + 1111 = 01111111
Therefore,
[ 7F_{16} = 01111111_2 ]
The leading zero in the first group is retained in the conversion shown. It may be omitted when writing the same binary value as an ordinary number, but keeping all four bits per hexadecimal digit makes the conversion method clear.
Key Idea: Replace each hexadecimal digit with exactly four binary bits. Do not change the order of the digits.
3. Converting Hexadecimal to Octal
The octal number system is base 8 and uses digits from 0 to 7. To convert hexadecimal to octal, first convert the hexadecimal number into binary. Then group the binary digits into sets of three, starting from the right. Each 3-bit group corresponds to one octal digit.
This two-stage method works because (8 = 2^3), so each octal digit represents exactly three binary bits.
Method
- Convert each hexadecimal digit into its 4-bit binary equivalent.
- Join the binary groups in the same order.
- Starting from the right, divide the binary digits into groups of three.
- If the leftmost group has fewer than three bits, add leading zeros to complete it.
- Convert each 3-bit group to its octal digit.
- Write the octal digits in the same order.
Step 1: Convert hexadecimal to binary.
| Hexadecimal digit | 4-bit binary |
|---|---|
2 | 0010 |
F | 1111 |
So,
[ 2F_{16} = 00101111_2 ]
Step 2: Group the binary digits into sets of three from the right.
00 101 111 becomes 000 101 111 after adding a leading zero to complete the first group.
Step 3: Convert each group to octal.
| 3-bit binary group | Octal digit |
|---|---|
000 | 0 |
101 | 5 |
111 | 7 |
Therefore, the octal digits are 057. The leading zero does not change the value, so the result can be written as:
[ 2F_{16} = 57_8 ]
Example 2: Convert (A3_{16}) to octalStep 1: Convert each hexadecimal digit to binary.
| Hexadecimal digit | 4-bit binary |
|---|---|
A | 1010 |
3 | 0011 |
Join the groups:
[ A3_{16} = 10100011_2 ]
Step 2: Group into 3 bits from the right.
10 100 011 becomes 010 100 011 after adding a leading zero.
Step 3: Convert each group to octal.
| 3-bit binary group | Octal digit |
|---|---|
010 | 2 |
100 | 4 |
011 | 3 |
Therefore,
[ A3_{16} = 243_8 ]
4. Binary Grouping Reference
The following reference values are useful when converting binary to octal.
| Binary | Octal | Binary | Octal |
|---|---|---|---|
000 | 0 | 100 | 4 |
001 | 1 | 101 | 5 |
010 | 2 | 110 | 6 |
011 | 3 | 111 | 7 |
Remember that a group of three binary bits can represent values from zero to seven, which matches the eight digits used in the octal system.
5. Why Do We Convert Through Binary?
Hexadecimal and octal are both convenient ways to represent binary data.
- One hexadecimal digit represents 4 bits.
- One octal digit represents 3 bits.
Because the group sizes differ, a hexadecimal digit cannot always be replaced directly by one octal digit. Converting through binary provides a reliable way to regroup the bits into threes.
The conversion changes only the representation of the number. The actual value remains the same.
6. Common Mistakes to Avoid
- Grouping from the left: When converting binary to octal, always form 3-bit groups starting from the right.
- Using four-bit groups for octal: Four-bit groups are used for hexadecimal. Octal requires groups of three.
- Changing the order: Keep the original order of the hexadecimal digits and binary groups.
- Forgetting leading zeros: Add zeros to the left of the first binary group when necessary. Do not add them to the right.
- Using invalid octal digits: An octal number can contain only digits
0through7. The digits8and9are not valid in base 8.
7. Exam-Focused Points
Key Idea: Each hexadecimal digit is converted to a 4-bit binary group. Preserve the order of the groups.
Key Idea: To convert hexadecimal to octal, convert to binary first, then group the binary digits into 3-bit groups from the right.
Key Idea: Add leading zeros only when needed to complete the leftmost group. Leading zeros do not change the number's value.
8. Quick Practice
Try these conversions. Use the hexadecimal-to-binary table and the 3-bit binary-to-octal reference above.
- Convert (5C_{16}) to binary.
- Convert (B4_{16}) to binary.
- Convert (7F_{16}) to octal.
- Convert (C2_{16}) to octal.
Answers
- (5C_{16} = 01011100_2)
- (B4_{16} = 10110100_2)
- (7F_{16} = 177_8)
- (C2_{16} = 302_8)
Summary
Hexadecimal-to-binary conversion is performed by replacing each hexadecimal digit with its 4-bit binary equivalent. To convert hexadecimal to octal, first write the number in binary, group the bits into sets of three from the right, add leading zeros if required, and convert each group to an octal digit. In both conversions, the number's value stays the same; only its representation changes.