Understanding Number Systems in Computer Organisation
In the realm of Computer Organisation and Architecture (COA), the number system serves as the foundational language for data representation and processing. While humans primarily use the decimal system, digital computers operate using binary signals. Understanding how these systems interact, convert, and represent complex data is essential for mastering hardware logic and assembly programming.
1. The Concept of Radix (Base)
The Radix or Base ($r$) of a number system defines the total number of unique digits (including zero) used to represent values.
- A number $N$ in base $r$ is represented as $(d_n d_{n-1} ... d_0 . d_{-1} d_{-2} ...)_r$.
- The value of each digit depends on its position, calculated as $d_i \times r^i$.
- The maximum value of a single digit in any system is always $r-1$.
2. Types of Number Systems
Decimal System (Base 10)
The standard human system using digits 0–9.
Binary System (Base 2)
The fundamental language of computers using 0 and 1 (bits), aligning with "ON/OFF" electronic states.
Octal System (Base 8)
Uses digits 0–7. Often shorthand for binary (1 octal digit = 3 bits).
Hexadecimal (Base 16)
Uses 0–9 and A–F. Widely used in memory addressing and color codes (1 hex digit = 4 bits).
3. Conversion Techniques
A. Any Base to Decimal
To convert a number from base $r$ to decimal, use the weighted sum method: Multiply each digit by $r$ raised to the power of its position and sum the results.
= 8 + 4 + 0 + 1 = (13)₁₀
B. Decimal to Any Base
Use Successive Division. Divide the decimal number by $r$ and record remainders. (LSB to MSB).
Use Successive Multiplication. Multiply the fraction by $r$ and record the integer part generated.
C. Shortcut: Binary ↔ Octal/Hex
Since $8 = 2^3$ and $16 = 2^4$, conversions are simplified through bit grouping:
| Conversion | Method |
|---|---|
| Binary to Octal | Group bits into sets of 3. |
| Binary to Hex | Group bits into sets of 4. |
| Reverse | Replace digit with its 3/4-bit binary equivalent. |
4. Representation of Signed Numbers
In digital systems, "signed" numbers represent both positive and negative values. Since computers cannot use symbols, the Most Significant Bit (MSB) is designated as the sign bit (0 for positive, 1 for negative).
I. Sign-Magnitude Representation
The MSB is the sign, and remaining bits represent absolute magnitude. Drawback: Two representations for zero (+0 and -0).
II. 1’s Complement
Invert all bits of the positive equivalent. Drawback: Still suffers from the "double zero" problem.
III. 2’s Complement (Standard)
Calculation: 1’s Complement + 1.
- Unique representation for zero.
- Simplifies subtraction to addition logic.
- More efficient hardware implementation.
5. Why This Matters in Computer Organisation
Memory Addressing
Hexadecimal is used to represent complex memory locations concisely.
Instruction Sets
Opcodes and operands are ultimately processed as binary bitstrings.
Efficiency
Optimize storage and minimize overflow errors during ALU operations.
Hardware Logic
Logic gates (AND, OR, NOT) operate directly on binary inputs.
"Digital computation is not just about math; it's about the elegant translation between human ideas and electrical states."