Review of Number Systems: Binary, Octal, and Hexadecimal Number Systems and Their Interconversion
In digital logic design (DLD) and computer science, the understanding of number systems is crucial as digital computers use different bases to represent data. The most commonly used number systems are binary, octal, and hexadecimal. These number systems are essential for understanding how computers perform arithmetic operations, how data is stored, and how different number formats are converted between each other.
1. Binary Number System
- The binary number system is the foundation of digital systems. It uses only two digits: 0 and 1, which are called bits (binary digits).
- A bit can represent two states: 0 (off) and 1 (on). These bits are used to represent all types of data in a computer.
- The place value for each bit in a binary number is based on powers of 2, starting from the rightmost digit.
Example:
The binary number 1101 represents:
- 1×23+1×22+0×21+1×20=8+4+0+1=13 in decimal.
2. Octal Number System
- The octal number system uses eight digits: 0, 1, 2, 3, 4, 5, 6, 7. It is a base-8 number system.
- Each octal digit represents exactly three binary digits (bits), because 23=8. This makes octal a convenient way to represent large binary numbers.
Example:
The octal number 15 represents:
- 1×81+5×80=8+5=13 in decimal.
3. Hexadecimal Number System
- The hexadecimal number system is a base-16 system that uses sixteen symbols: 0-9 for values 0 to 9 and A-F for values 10 to 15.
- Hexadecimal is widely used in computer science because it is more compact than binary and easier for humans to read and interpret. Each hexadecimal digit represents exactly four binary digits (bits), because 24=16.
Example:
The hexadecimal number 1A represents:
- 1×161+A×160=16+10=26 in decimal.
4. Interconversion Between Binary, Octal, Decimal, and Hexadecimal
Understanding how to convert between these number systems is very important for programming, data representation, and digital logic design. The conversion can be done either by direct methods or through intermediate representations (like binary).
(a) Binary to Octal Conversion
- Step 1: Group the binary number into groups of three bits, starting from the right. If there are fewer than three bits on the leftmost group, pad with leading zeros.
- Step 2: Convert each group of three binary bits into its octal equivalent.
Example: Convert binary 101110 to octal.
- Group binary into triplets:
101 110
- Convert each group to octal:
101 in binary = 5 in octal
110 in binary = 6 in octal
- The result is
56 in octal.
(b) Binary to Hexadecimal Conversion
- Step 1: Group the binary number into groups of four bits, starting from the right. If there are fewer than four bits on the leftmost group, pad with leading zeros.
- Step 2: Convert each group of four binary bits into its hexadecimal equivalent.
Example: Convert binary 1011101 to hexadecimal.
- Group binary into nibbles (groups of 4 bits):
0101 1101
- Convert each group to hexadecimal:
0101 in binary = 5 in hexadecimal
1101 in binary = D in hexadecimal
- The result is
5D in hexadecimal.
(c) Octal to Binary Conversion
- Step 1: Convert each octal digit to its 3-bit binary equivalent.
Example: Convert octal 56 to binary.
- Convert each octal digit to binary:
5 in octal = 101 in binary
6 in octal = 110 in binary
- Combine the binary values:
101 110 → 101110
(d) Hexadecimal to Binary Conversion
- Step 1: Convert each hexadecimal digit to its 4-bit binary equivalent.
Example: Convert hexadecimal 3F to binary.
- Convert each hexadecimal digit to binary:
3 in hexadecimal = 0011 in binary
F in hexadecimal = 1111 in binary
- Combine the binary values:
0011 1111 → 00111111
(e) Octal to Hexadecimal Conversion
- Step 1: Convert the octal number to binary.
- Step 2: Convert the resulting binary number to hexadecimal.
Example: Convert octal 56 to hexadecimal.
-
Convert octal 56 to binary:
5 in octal = 101 in binary
6 in octal = 110 in binary
- So,
56 in octal = 101 110 in binary.
-
Convert binary 101110 to hexadecimal:
- Group binary into nibbles:
0010 1110
- Convert each group to hexadecimal:
0010 in binary = 2 in hexadecimal
1110 in binary = E in hexadecimal
- The result is
2E in hexadecimal.
(f) Hexadecimal to Octal Conversion
- Step 1: Convert the hexadecimal number to binary.
- Step 2: Convert the resulting binary number to octal.
Example: Convert hexadecimal 3F to octal.
-
Convert hexadecimal 3F to binary:
3 in hexadecimal = 0011 in binary
F in hexadecimal = 1111 in binary
- So,
3F in hexadecimal = 00111111 in binary.
-
Convert binary 00111111 to octal:
- Group binary into triplets:
000 111 111
- Convert each group to octal:
000 in binary = 0 in octal
111 in binary = 7 in octal
111 in binary = 7 in octal
- The result is
77 in octal.
5. Summary of Interconversion
| From |
To |
Method |
| Binary |
Octal |
Group binary digits into groups of 3 and convert each group into an octal digit. |
| Binary |
Hexadecimal |
Group binary digits into groups of 4 and convert each group into a hexadecimal digit. |
| Octal |
Binary |
Convert each octal digit into a 3-bit binary equivalent. |
| Octal |
Hexadecimal |
Convert octal to binary and then convert the binary result into hexadecimal. |
| Hexadecimal |
Binary |
Convert each hexadecimal digit into a 4-bit binary equivalent. |
| Hexadecimal |
Octal |
Convert hexadecimal to binary and then convert the binary result into octal. |
6. Summary
- Binary is the base-2 number system and is the language of computers.
- Octal is the base-8 system and is often used as a shorthand for binary.
- Hexadecimal is the base-16 system and is commonly used in computer science for compact representation of binary numbers.
- Interconversion between these systems is essential for computer engineers and programmers, and understanding the rules of conversion makes it easier to deal with digital data and memory addressing.
By mastering conversions between binary, octal, and hexadecimal systems, you can effectively work with digital logic design and other aspects of computer science.