C. S Chapter 2 Note Utube
C. S Chapter 2 Note Utube
Number Systems
This chapter introduces different number systems and how to convert numbers
between them. Computers use digits to represent quantities, and different number
systems offer various ways to express numeric values.
Decimal
Binary
Octal
Hexadecimal
It has 10 numbers: 0 to 9.
The base of the decimal number system is 10.
It is a positional number system.
To calculate the number, we multiply these positions with the respective digits and
add them up:
Page 1
Created by Turbolearn AI
2 1 0
1 ∗ 10 + 2 ∗ 10 + 3 ∗ 10 = 100 + 20 + 3 = 123
1 has the highest weight and is known as the MSB (Most Significant Bit).
3 has the lowest weight and is known as the LSB (Least Significant Bit).
Fractional Parts
For fractional parts, consider the number 123.45:
Base Consideration
The decimal number system has a base of 10, so we take the power of 10. In other
number systems, we consider their respective bases.
Page 2
Created by Turbolearn AI
Consider the binary number 100, which is equivalent to the decimal number 4. To
find the positional value:
0
2
1
2
2
2
We can write the base of the decimal number system as 10 to indicate that the
number is represented in the decimal number system: 4 10
Calculation:
−1 −2
0 ∗ 2 + 1 ∗ 2 = 0 + 1/4 = 0.25
So, the binary number 100.01 is equivalent to the decimal number 4.25 .
2 10
Page 3
Created by Turbolearn AI
To solve this, we take the power of 8 because the base of the octal number system is
8. The left side of the octal point will be the positive power of 8, and the right side
will be the negative power of 8.
0
8
1
8
2
8
−1
8
−2
8
Octal Calculation
Continuing the calculation from the previous example:
3 ∗ 64 + 7 ∗ 8 + 1 ∗ 1 + 2 ∗ (1/8) + 4 ∗ (1/64)
To simplify, we solve:
Page 4
Created by Turbolearn AI
Base of 16
Uses 16 digits: 0-9 and A-F
A represents 10, B is 11, C is 12, D is 13, E is 14, and F is 15
Positional number system
Page 5
Created by Turbolearn AI
1. Create a table to represent weights. Multiply each weight with the digits:
3 * 162
C * 161
F * 160
1 * 16-1
A * 16-2
2. Substitute values:
3 * 162 = 3 * 256
C = 12
F = 15
A = 10
3. Solve:
3 * 256 + 12 * 16 + 15 * 1 + 1 * (1/16) + 10 * (1/162)
768 + 192 + 15 + (1/16) + 10/(256)
768 + 192 + 15 + 0.0625 + 0.0390
4. Simplify:
768 + 192 + 15 = 975
0.0625 + 0.0390 = 0.1015
5. Add:
975 + 0.1015 = 975.1015
Page 6
Created by Turbolearn AI
1. Divide 11 by 2:
11 ÷ 2 = 5, Remainder = 1
2. Divide 5 by 2:
5 ÷ 2 = 2, Remainder = 1
3. Divide 2 by 2:
2 ÷ 2 = 1, Remainder = 0
4. Divide 1 by 2:
1 ÷ 2 = 0, Remainder = 1
5. Record remainders from bottom to top: 1011
To cross-check, convert the binary number back to decimal using positional values:
Page 7
Created by Turbolearn AI
1. Divide 5 by 2:
5 ÷ 2 = 2, Remainder = 1
2. Divide 2 by 2:
2 ÷ 2 = 1, Remainder = 0
3. Divide 1 by 2:
1 ÷ 2 = 0, Remainder = 1
4. Record remainders from bottom to top: 101
To cross-check, convert the binary number back to decimal using positional values:
Practice converting the decimal number 121 to binary for additional practice.
So, 0.812510
= 0.11012
Page 8
Created by Turbolearn AI
Cross-check: 2 −1 −2
+ 2 = 1/2 + 1/4 = 0.5 + 0.25 = 0.75
Note: If you don't get 0 after several steps, perform the multiplication four times and
then note down the number.
Practice Example: Convert 521.17 (decimal) to binary. (Solve it and post your answer
in the comments!)
Binary to Decimal
To convert from binary to decimal, take the positional value, multiply it by the
respective digit, and add them up.
2 1 0
1 ∗ 2 + 0 ∗ 2 + 1 ∗ 2 = 4 + 0 + 1 = 5
So, 101 2
= 510
You can cross-check by converting the result back to binary using repeated division.
Decimal to Octal
To convert from decimal to octal, repeatedly divide by 8.
Page 9
Created by Turbolearn AI
1. 123/8 = 15 remainder 3
2. 15/8 = 1 remainder 7
3. 1/8 = 0 remainder 1
1. 266/8 = 33 remainder 2
2. 33/8 = 4 remainder 1
3. 4/8 = 0 remainder 4
Octal to Decimal ➮
Take the positional value and multiply it by the respective digit, then add them up.
Page 10
Created by Turbolearn AI
Multiply each digit by its positional value (powers of 8). For the octal number 372:
3 ⋅ 8 + 7 ⋅ 8 + 2 ⋅ 8 = 3 ⋅ 64 + 7 ⋅ 8 + 2 = 192 + 56 + 2 = 250 So, 372 in octal is 250
2 1 0
in decimal.
Every bit has its own positional value or weight in the binary number
system, where the positional values are powers of 2.
Octal Binary
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
4 is 100
7 is 111
2 is 010
1 is 001
3 is 011
6 is 110
Page 11
Created by Turbolearn AI
111 is 7
100 is 4
010 is 2
423 ÷ 16 = 26 remainder 7
26 ÷ 16 = 1 remainder 10 (A)
1 ÷ 16 = 0 remainder 1
Page 12
Created by Turbolearn AI
Reading the remainders from bottom to top, we get D6. Therefore, the hexadecimal
equivalent of 214 is D6.
2 ∗ 256 + 10 ∗ 16 + 15 ∗ 1
2
5 ∗ 16 + 6 ∗ 1 + 0 + 8/(16 )
80 + 6 + 0 + 8/256
86 + 0.0390 = 86.0390
Page 13
Created by Turbolearn AI
1. Group the binary digits into sets of four, starting from the right.
2. Convert each group of four binary digits into its hexadecimal equivalent.
For example, let's take a binary number and convert it to hexadecimal. Suppose we
have the binary number 1010 1011 0010.
To find the hexadecimal equivalent of a binary number, we can use the positional
values of the binary number system, which are powers of 2 (1, 2, 4, 8). We add the
positional values corresponding to the bits that are 1.
0000 0-0-0-0 0 0
0001 0-0-0-1 1 1
0010 0-0-2-0 2 2
0011 0-0-2-1 2+1 3
0100 0-4-0-0 4 4
0101 0-4-0-1 4+1 5
0110 0-4-2-0 4+2 6
0111 0-4-2-1 4+2+1 7
1000 8-0-0-0 8 8
1001 8-0-0-1 8+1 9
1010 8-0-2-0 8+2 A
1011 8-0-2-1 8+2+1 B
1100 8-4-0-0 8+4 C
1101 8-4-0-1 8+4+1 D
1110 8-4-2-0 8+4+2 E
1111 8-4-2-1 8 + 4 + 2 +1 F
Page 14
Created by Turbolearn AI
So, the hexadecimal equivalent of the binary number 1010 1011 0010 is 2BA.
We can ignore the bits that are zero and only add the positional values for the bits
that are one. For instance, with 1010, we calculate 8 + 2 = 10, which corresponds to
'A' in hexadecimal. Similarly, for 1011, we have 8 + 2 + 1 = 11, which is 'B' in
hexadecimal.
Let's take the hexadecimal number 2F9 as an example and convert it to binary.
1. Write down the positional values of the binary number system (8, 4, 2, 1).
2. Find the combination of these values that add up to the number you want to
convert.
3. Write a '1' bit for the values that are part of the combination and a '0' for the
others.
For the number 2: we can obtain it directly from the value 2, therefore the binary
equivalent is 0010.
For F: the value of F is 15, which is 8 + 4 + 2 + 1. So, all bits are 1, and the binary
equivalent of F is 1111.
For 9: 9 is 8 + 1, so we write '1' for 8 and 1, and '0' for the others. The binary
equivalent of 9 is 1001.
Binary Addition
To perform binary addition, follow these rules:
Page 15
Created by Turbolearn AI
0+0=0
0+1=1
1+0=1
1 + 1 = 10 (write 0, carry 1)
1 + 1 + 1 = 11 (write 1, carry 1)
1101
+ 0011
------
1100
1. 0 + 0 = 0
2. 1 + 1 = 10 (write 0, carry 1)
3. 1 + 0 + 1 (carry) = 10 (write 0, carry 1)
4. 1 + 0 + 1 (carry) = 10 (write 1)
Encoding Systems
Now, let's discuss how computers represent letters, symbols, and special characters
using different encoding systems.
ASCII
ASCII (American Standard Code for Information Interchange): An
encoding system where each character on the keyboard is associated with
an alphanumeric code ranging from 0 to 127.
ISCII
ISCII (Indian Script Code for Information Interchange): An encoding
system used for Indian scripts, accommodating the numerous languages
used in India.
Unicode
Page 16
Created by Turbolearn AI
Page 17