Section 26: Miscellaneous #1
Number Systems
- Binary: Base 2 \(\rightarrow \{0, 1\}\)
- Octal: Base 8 \(\rightarrow \{0, 1, 2, 3, 4, 5, 6, 7\}\)
- Decimal: Base 10 \(\rightarrow \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\}\)
- Hexadecimal: Base 16 \(\rightarrow \{0, 1, \dots, 9, A, B, C, D, E, F\}\)
Comparison Table
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 3 | 11 | 3 | 3 |
| 4 | 100 | 4 | 4 |
| 5 | 101 | 5 | 5 |
| 6 | 110 | 6 | 6 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
Conversion of Number Systems
1. Decimal to Binary
Method: Divide by 2 and take the remainder from end (bottom) to start (top).
Example: \(50_{10} \rightarrow (?)_{2}\)
Result: \(50_{10} = 110010_{2}\)
2. Decimal to Octal
Method: Divide by 8 and take the remainder from end to start.
Example: \(50_{10} \rightarrow (?)_{8}\)
Result: \(50_{10} = 62_{8}\)
3. Decimal to Hexadecimal
Method: Divide by 16 and take the remainder from end to start.
Example: \(50_{10} \rightarrow (?)_{16}\)
Result: \(50_{10} = 32_{16}\)
4. Binary to Decimal
Method: Sum of (Digit \(\times\) Base\(^{\text{position}}\)).
Example: \(11110_{2} \rightarrow (?)_{10}\)
Result: \(11110_{2} = 30_{10}\)
5. Octal to Decimal
Example: \(34_{8} \rightarrow (?)_{10}\)
Result: \(34_{8} = 28_{10}\)
6. Hexadecimal to Decimal
Example: \(1E_{16} \rightarrow (?)_{10}\)
Result: \(1E_{16} = 30_{10}\)
7. Octal to Binary
Method: Convert each octal digit to a 3-bit binary number.
Example: \(72_{8} \rightarrow (?)_{2}\)
- \(7 \rightarrow 111\)
- \(2 \rightarrow 010\)
Result: \(72_{8} = 111010_{2}\)
8. Binary to Octal
Method: Group bits in 3s from right to left (LSB to MSB).
Example: \(10110110_{2} \rightarrow (?)_{8}\)
- \(110 \rightarrow 6\)
- \(110 \rightarrow 6\)
- \(010 \rightarrow 2\) (added padding zero)
Result: \(10110110_{2} = 266_{8}\)
9. Hexadecimal to Binary
Method: Convert each hex digit to a 4-bit binary number.
Example: \(3C4_{16} \rightarrow (?)_{2}\)
- \(3 \rightarrow 0011\)
- \(C \rightarrow 1100\)
- \(4 \rightarrow 0100\)
Result: \(3C4_{16} = 1111000100_{2}\) (Leading zeros can be omitted)
10. Binary to Hexadecimal
Method: Group bits in 4s from right to left.
Example: \(10011001010_{2} \rightarrow (?)_{16}\)
- \(1010 \rightarrow A\)
- \(1100 \rightarrow C\)
- \(0100 \rightarrow 4\) (added padding zeros)
Result: \(10011001010_{2} = 4CA_{16}\)
11. Octal to Hexadecimal
Note: There is no direct method. Strategy: Octal \(\rightarrow\) Binary \(\rightarrow\) Hexadecimal.
Example: \(276_{8} \rightarrow (?)_{16}\)
-
Octal to Binary:
- \(2 \rightarrow 010\)
- \(7 \rightarrow 111\)
- \(6 \rightarrow 110\)
- Binary: \(010111110_{2}\)
-
Binary to Hexadecimal:
- Group by 4s:
000010111110 - \(1110 \rightarrow E\)
- \(1011 \rightarrow B\)
- \(0 \rightarrow 0\)
- Group by 4s:
Result: \(276_{8} = BE_{16}\)
12. Hexadecimal to Octal
Note: No direct method. Strategy: Hexadecimal \(\rightarrow\) Binary \(\rightarrow\) Octal.
Example: \(276_{16} \rightarrow (?)_{8}\)
-
Hexadecimal to Binary:
- \(2 \rightarrow 0010\)
- \(7 \rightarrow 0111\)
- \(6 \rightarrow 0110\)
- Binary: \(001001110110_{2}\)
-
Binary to Octal:
- Group by 3s:
001001110110 - \(110 \rightarrow 6\)
- \(110 \rightarrow 6\)
- \(001 \rightarrow 1\)
- \(001 \rightarrow 1\)
- Group by 3s:
Result: \(276_{16} = 1166_{8}\)