Unit 1: Computer Systems & Organisation
Chapter 2: Number Systems and Conversions
1. Introduction to Positional Number Systems
In a positional number system, the numerical value represented by a digit depends on: 1. The digit itself. 2. The position of the digit within the number. 3. The Radix or Base ($r$) of the number system.
$$\text{Value} = \sum_{i} d_i \times r^i$$
The Four Fundamental Number Systems in Computing
| Number System | Base ($r$) | Allowed Digits / Symbols | Example |
|---|---|---|---|
| Binary | $2$ | $0, 1$ | $(110101)_2$ |
| Octal | $8$ | $0, 1, 2, 3, 4, 5, 6, 7$ | $(745)_8$ |
| Decimal | $10$ | $0, 1, 2, 3, 4, 5, 6, 7, 8, 9$ | $(489)_{10}$ |
| Hexadecimal | $16$ | $0-9, \text{A}(10), \text{B}(11), \text{C}(12), \text{D}(13), \text{E}(14), \text{F}(15)$ | $(2\text{A}7\text{F})_{16}$ |
2. Conversions Between Number Systems
A. Decimal to Other Bases (Repeated Division)
To convert a decimal integer to base $r$: - Divide the number successively by $r$. - Record the remainder at each step. - Continue division until the quotient becomes $0$. - Write remainders from bottom to top (Last remainder is Most Significant Bit - MSB; first is Least Significant Bit - LSB).
Example: Convert $(43)_{10}$ to Binary:
43 / 2 = 21 remainder 1 (LSB)
21 / 2 = 10 remainder 1
10 / 2 = 5 remainder 0
5 / 2 = 2 remainder 1
2 / 2 = 1 remainder 0
1 / 2 = 0 remainder 1 (MSB)
Reading bottom-to-top: (101011)_2
Example: Convert $(125)_{10}$ to Hexadecimal:
125 / 16 = 7 remainder 13 (13 is D in Hex)
7 / 16 = 0 remainder 7
Reading bottom-to-top: (7D)_16
B. Any Base to Decimal (Positional Expansion)
Multiply each digit by its positional weight ($r^n$) and sum the results.
Example 1: Convert $(11010)_2$ to Decimal: $$(11010)2 = 1 \times 2^4 + 1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 0 \times 2^0$$ $$= 16 + 8 + 0 + 2 + 0 = (26){10}$$
Example 2: Convert $(357)_8$ to Decimal: $$(357)8 = 3 \times 8^2 + 5 \times 8^1 + 7 \times 8^0$$ $$= 3 \times 64 + 5 \times 8 + 7 \times 1 = 192 + 40 + 7 = (239){10}$$
Example 3: Convert $(\text{2B})_{16}$ to Decimal: $$(\text{2B}){16} = 2 \times 16^1 + 11 \times 16^0 = 32 + 11 = (43){10}$$
C. Binary $\longleftrightarrow$ Octal (Group of 3 Bits)
Since $2^3 = 8$, exactly 3 binary bits represent one octal digit:
| Octal Digit | Binary (3-bit) | Octal Digit | Binary (3-bit) |
|---|---|---|---|
| 0 | 000 | 4 | 100 |
| 1 | 001 | 5 | 101 |
| 2 | 010 | 6 | 110 |
| 3 | 011 | 7 | 111 |
- Binary to Octal: Group bits in 3s starting from right (pad leading zeros if needed).
- $(11010111)_2 o \underbrace{011}_3\ \underbrace{010}_2\ \underbrace{111}_7 o (327)_8$
- Octal to Binary: Replace each octal digit with its 3-bit binary equivalent.
- $(645)_8 o 110\ 100\ 101 o (110100101)_2$
D. Binary $\longleftrightarrow$ Hexadecimal (Group of 4 Bits)
Since $2^4 = 16$, exactly 4 binary bits represent one hexadecimal digit:
- Binary to Hexadecimal: Group bits in 4s from right to left.
- $(110111101010)2 o \underbrace{1101}{\text{D}}\ \underbrace{1110}{\text{E}}\ \underbrace{1010}{\text{A}} o (\text{DEA})_{16}$
- Hexadecimal to Binary: Write 4-bit binary for each hex digit.
- $(\text{F}3\text{C}){16} o \underbrace{1111}{\text{F}}\ \underbrace{0011}{3}\ \underbrace{1100}{\text{C}} o (111100111100)_2$
3. Representation of Signed Numbers: 1's and 2's Complement
Digital computers execute subtraction using addition hardware via complements.
1's Complement
- Obtained by inverting every bit: replace all $0$s with $1$s and all $1$s with $0$s.
- Example: 1's complement of $(10110010)_2$ is $(01001101)_2$.
2's Complement (Standard for Arithmetic in Modern CPUs)
$$\text{2's Complement} = \text{1's Complement} + 1$$
Example: Find the 8-bit 2's complement of $+25$ to represent $-25$:
1. Binary of $+25$ in 8-bits: 00011001
2. 1's Complement (invert bits): 11100110
3. Add 1: 11100110 + 1 = 11100111
4. Hence, $-25$ in 8-bit 2's complement is 11100111.
4. Text and Character Encoding Standards
Computers store characters (letters, punctuation, symbols) as integer codes:
- ASCII (American Standard Code for Information Interchange):
- 7-bit ASCII: Encodes $2^7 = 128$ characters ($0$ to $127$).
'A'to'Z': $65$ to $90$'a'to'z': $97$ to $122$'0'to'9': $48$ to $57$
- 8-bit Extended ASCII: Encodes $2^8 = 256$ characters ($0$ to $255$).
- ISCII (Indian Script Code for Information Interchange):
- 8-bit character code designed specifically for Indian languages (Devanagari, Bengali, Tamil, etc.).
- Unicode:
- Universal character encoding covering characters from all living writing systems, historic scripts, mathematical symbols, and emojis.
- UTF-8: Variable-length (1 to 4 bytes). Backwards-compatible with 7-bit ASCII. Dominant on the modern web ($>98\%$ of all web pages).
- UTF-16: Variable-length (2 or 4 bytes).
- UTF-32: Fixed 4 bytes per character.
5. Board Exam Practice Questions & Solutions
Q1. Convert $(275)_{10}$ into its Hexadecimal and Octal equivalents.
Answer:
- To Hexadecimal:
$275 \div 16 = 17$ rem $3$
$17 \div 16 = 1$ rem $1$
$1 \div 16 = 0$ rem $1$
Reading bottom-up: $(113)_{16}$
- To Octal:
$275 \div 8 = 34$ rem $3$
$34 \div 8 = 4$ rem $2$
$4 \div 8 = 0$ rem $4$
Reading bottom-up: $(423)_{8}$
Q2. What is the value of $(1011101)_2$ converted directly to Hexadecimal?
Answer:
Group bits in sets of 4 from right:
$0101\ 1101$
$0101 = 5$
$1101 = 13 = \text{D}$
Result: $(5\text{D})_{16}$
Q3. State the primary difference between ASCII and Unicode.
Answer:
Standard ASCII uses 7 bits (or 8 bits in extended ASCII), restricting its vocabulary to at most 128 (or 256) characters—predominantly Latin English characters and control symbols. Unicode is a universal encoding standard that uses variable-length encoding (1 to 4 bytes in UTF-8) to represent over 149,000 characters across virtually every global language, mathematical notation, and emoji set.