Computer Number Systems: Binary, Decimal, Octal, and Hexadecimal
Computers operate using digital logic, which relies on the Binary Number System (0 and 1). To understand how data is processed, we must learn how to convert between different number systems used in computing.
📊 Quick Reference Table
| Number System | Base | Digits / Range |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0, 1, 2, 3, 4, 5, 6, 7 |
| Decimal | 10 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 |
| Hexadecimal | 16 | 0-9 and A-F (A=10, B=11, C=12, D=13, E=14, F=15) |
1. Decimal to Binary
To convert a Decimal number to Binary, we repeatedly divide the number by 2 and track the remainders.
Steps:
- Divide the decimal number by 2.
- Write down the remainder (0 or 1).
- Repeat the process with the quotient until it becomes 0.
- Read the remainders from bottom to top.
Example:Convert (13)₁₀ to Binary.
- 13 ÷ 2 = 6, Remainder: 1
- 6 ÷ 2 = 3, Remainder: 0
- 3 ÷ 2 = 1, Remainder: 1
- 1 ÷ 2 = 0, Remainder: 1 Result: (1101)₂
2. Binary to Decimal
To convert Binary to Decimal, multiply each digit by 2 raised to the power of its position (starting from 0 on the right).
Formula: d₀×2⁰ + d₁×2¹ + d₂×2² ...
Example: Convert (1011)₂ to Decimal.
- (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰)
- 8 + 0 + 2 + 1 = 11 Result: (11)₁₀
3. Binary to Octal & Hexadecimal
These conversions are easiest when done using the "Grouping" method.
Binary to Octal (Base 8)
- Group the binary digits into sets of 3 starting from the right.
- Assign weights (4, 2, 1) to each group.
- Example: (110101)₂ -> (110) (101) -> 6 5 -> (65)₈
Binary to Hexadecimal (Base 16)
- Group the binary digits into sets of 4 starting from the right.
- Assign weights (8, 4, 2, 1) to each group.
- Example: (11011011)₂ -> (1101) (1011) -> 13 11 -> (DB)₁₆
4. Hexadecimal Table (A-F)
| Decimal | Hexadecimal | Binary (4-bit) |
|---|---|---|
| 10 | A | 1010 |
| 11 | B | 1011 |
| 12 | C | 1100 |
| 13 | D | 1101 |
| 14 | E | 1110 |
| 15 | F | 1111 |
Always remember that theBaserepresents the number of unique digits in that system. A higher base allows us to represent large numbers with fewer digits (compact representation).