Binary, Octal, Decimal & Hexadecimal Number Systems
Bridging human logic and machine execution: A comprehensive guide for Computer Science students.
Introduction
In computer science, data represents electronic states. Number systems bridge human logic and machine execution, crucial for understanding digital logic and computer architecture. A mathematical method for representing numbers using a set of symbols (digits). Most are positional, where a digit's value depends on its position relative to the decimal point. The number of unique symbols is the Base or Radix.
1 Core Number Systems
Decimal (Base 10)
- Base (r): 10
- Digits: 0 through 9
- Weight: Powers of 10 (10⁰, 10¹, 10²...)
523 = (5×10²) + (2×10¹) + (3×10⁰)
Binary (Base 2)
- Base (r): 2
- Digits: 0 and 1 ("bits")
- Importance: Fundamental to electronic logic.
ON = 1 | OFF = 0
Octal (Base 8)
- Base (r): 8
- Digits: 0 through 7
- Usage: Groups binary digits into 3s.
Hexadecimal (Base 16)
- Base (r): 16
- Digits: 0-9 and A-F (A=10...F=15)
- Usage: Memory addresses, CSS colors.
The 'Four-Bit' Relationship Chart
Master the Conversions
A. Any Base to Decimal
Method: Sum of Weights
Multiply each digit by its positional weight and sum the results.
Binary 1011 → (1×2³) + (0×2²) + (1×2¹) + (1×2⁰) = 8 + 0 + 2 + 1 = 11₁₀
B. Decimal to Any Base
Method: Successive Division
Repeatedly divide the decimal number by the target base, recording remainders from bottom to top.
C. Binary to Hexadecimal
Method: Grouping (Nibbles)
Group binary digits into sets of four from right to left (LSB).
Summary for Exams
| System | Base | Digits | Common Application |
|---|---|---|---|
| Decimal | 10 | 0–9 | Human calculations |
| Binary | 2 | 0, 1 | Machine logic / CPU |
| Octal | 8 | 0–7 | Legacy compact binary |
| Hexadecimal | 16 | 0–F | Memory addresses, Debugging |
★ Why Base 2?
Hardware Compatibility: Bistable electronic circuits simplify design, reduce noise sensitivity, and increase reliability. Two states are easier to maintain than ten.
★ Why Base 16?
Efficiency: Since 16 is 2⁴, four binary bits (a "nibble") map perfectly to one hex digit, making it an efficient shorthand for long binary strings.
Final Takeaway
Mastering number systems is essential for understanding computer architecture and for skills like debugging and low-level code optimization. Fluency between Binary, Decimal, and Hexadecimal is a fundamental computer science skill that will serve you throughout your career.