ALL SIR NOTES HAVE BEEN UPLOADED HERE.
Subject Teacher: Bhagirath Singh Chauhan #9829275869
Number systems are the technique to represent numbers in the computer system architecture, every value that you are saving or getting into/from computer memory has a defined number system. Computer architecture supports following number systems.
Binary number system
Octal number system
Decimal number system
Hexadecimal (hex) number system
BINARY NUMBER SYSTEM
A Binary number system has only two digits that are 0 and 1. Every number (value) represents with 0 and 1 in this number system. The base of binary number system is 2, because it has only two digits.
OCTAL NUMBER SYSTEM
Octal number system has only eight (8) digits from 0 to 7. Every number (value) represents with 0,1,2,3,4,5,6 and 7 in this number system. The base of octal number system is 8, because it has only 8 digits.
DECIMAL NUMBER SYSTEM
Decimal number system has only ten (10) digits from 0 to 9. Every number (value) represents with 0,1,2,3,4,5,6,7,8 and 9 in this number system. The base of decimal number system is 10, because it has only 10 digits.
HEXADECIMAL NUMBER SYSTEM
A Hexadecimal number system has sixteen (16) alphanumeric values from 0 to 9 and A to F. Every number (value) represents with 0,1,2,3,4,5,6, 7,8,9,A,B,C,D,E and F in this number system. The base of hexadecimal number system is 16, because it has 16 alphanumeric values. Here A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15. Number System Base(Radix) Used Digits Example
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,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
The number based conversions are essential in digital electronics. Mostly in all digital system, we have the input in decimal format but it takes as binary number for the computation by decimal to binary conversion and we use the hexadecimal number to make coding for microprocessor but it converts that to binary for computation after the computation the result will be in hexadecimal format by inverse conversion.
Binary to Octal and Vice-versa
One of the easiest ways to achieve this conversion is by constructing a table. With the help of table we can convert from binary to octal and from octal to binary.
Steps to construct table-
8=2^3, so to construct a table we will take three columns and 8 rows.
8/2=4, in first column first 4 rows will have zeros and rest 4 have ones.
Similarly, in second column, 1st two rows will have zeros then next 2 rows will have ones and so on.
In third column, 1st row have zero, second row have 1 and so on…
Now, let us construct the required table
0
0
0
0
1
0
0
1
2
0
1
0
3
0
1
1
4
1
0
0
5
1
0
1
6
1
1
0
7
1
1
1
Using this table you can easily convert octal to binary. In order to convert binary to octal make group of 3 elements from left to right and write the corresponding octal number.
Eg.
?
Group binary number from right to left-
-----
Go through the examples as discussed in the class.
If binary number has both integral and fractional part, then do grouping from right to left(from decimal position) for integral and for fractional part grouping is done from left to right.
Binary to Hexadecimal and Vice-versa
Similarly, you can design table for binary to hexadecimal and vice-versa conversion.
0
0
0
0
0
1
0
0
0
1
2
0
0
1
0
3
0
0
1
1
4
0
1
0
0
5
0
1
0
1
6
0
1
1
0
7
0
1
1
1
8
1
0
0
0
9
1
0
0
1
A
1
0
1
0
B
1
0
1
1
C
1
1
0
0
D
1
1
0
1
E
1
1
1
0
F
1
1
1
1
Here, grouping done for 4 elements and rest operations are similar to binary <- -> Octal.
Decimal to Binary
Conversion steps:
Divide the number by 2.
Get the integer quotient for the next iteration.
Get the remainder for the binary digit.
Repeat the steps until the quotient is equal to 0.
Example #1 Convert 1310 to binary: Division by 2 Quotient Remainder Bit # 13/2 6 1 0 6/2 3 0 1 3/2 1 1 2 1/2 0 1 3 So 1310 = 11012 Example #2 Convert 17410 to binary: Division by 2 Quotient Remainder Bit # 174/2 87 0 0 87/2 43 1 1 43/2 21 1 2 21/2 10 1 3 10/2 5 0 4 5/2 2 1 5 2/2 1 0 6 1/2 0 1 7 So 17410 = 101011102
Similarly, you can do the conversion from decimal to octal and hexadecimal; replace 2 by 8 and 16 respectively.
Decimal to Binary with fraction part
Demonstration through an example-
=
DESCRIPTIONS
We convert the whole number and fractional parts separately and then combine the results.
WHOLE NUMBER PART
The whole number part of 85.375 is 85. Divide this number repeatedly by 2 until the quotient becomes 0.
When 85 is divided by 2, the quotient is 42 and the remainder is 1.
When 42 is divided by 2, the quotient is 21 and the remainder is 0.
When 21 is divided by 2, the quotient is 10 and the remainder is 1.
When 10 is divided by 2, the quotient is 5 and the remainder is 0.
When 5 is divided by 2, the quotient is 2 and the remainder is 1.
When 2 is divided by 2, the quotient is 1 and the remainder is 0.
When 1 is divided by 2, the quotient is 0 and the remainder is 1.
Write the remainders from bottom to top.
) =
FRACTIONAL PART
The fractional part of 85.375 is 0.375. Multiply the fractional part repeatedly by 2 until it becomes 0.
0.375 × 2 = 0.750
0.750 × 2 = 1.500
0.500 × 2 = 1.000
From top to bottom, write the integer parts of the results to the fractional part of the number in base 2.
(0.375)10 = (0.011)2
OVERALL RESULT
Combine the whole number and fractional parts to obtain the overall result.
(85.375)10 = (1010101)2 + (0.011)2 = (1010101.011)2
Decimal to Octal with fractional part
Demonstration through an example-
(125.85)10 = (1331.31212121...)8
DESCRIPTIONS
We convert the whole number and fractional parts separately and then combine the results.
WHOLE NUMBER PART
The whole number part of 125.85 is 125. Divide this number repeatedly by 8 until the quotient becomes 0.
When 125 is divided by 8, the quotient is 15 and the remainder is 5.
When 15 is divided by 8, the quotient is 1 and the remainder is 7.
Poornima College of Enginnering Unit-II (Number System)
Subject Teacher: Bhagirath Singh Chauhan #9829275869 Page: 5
When 1 is divided by 8, the quotient is 0 and the remainder is 1.
Write the remainders from bottom to top.
(125)10 = (175)8
FRACTIONAL PART
The fractional part of 125.85 is 0.85. Multiply the fractional part repeatedly by 8 until it becomes 0. Stop after a number of steps if the fractional part does not become 0.
0.85 × 8 = 6.80
0.80 × 8 = 6.40
0.40 × 8 = 3.20
0.20 × 8 = 1.60
0.60 × 8 = 4.80
............
From top to bottom, write the integer parts of the results to the fractional part of the number in base 4.
(0.85)10 = (0.66314...)8
OVERALL RESULT
Combine the whole number and fractional parts to obtain the overall result.
(125.85)10 = (175)8 + (0.66314...)8 = (125.66314...)8
Decimal to Octal with fractional part
Demonstration through an example-
(125.25)10 = (7D.4)16
DESCRIPTIONS
We convert the whole number and fractional parts separately and then combine the results.
WHOLE NUMBER PART
The whole number part of 125.25 is 125. Divide this number repeatedly by 16 until the quotient becomes 0.
When 125 is divided by 16, the quotient is 7 and the remainder is 13 = D.
When 7 is divided by 16, the quotient is 0 and the remainder is 7.
Write the remainders from bottom to top.
(125)10 = (7D)16
FRACTIONAL PART
The fractional part of 125.25 is 0.25. Multiply the fractional part repeatedly by 16 until it becomes 0.
0.25 × 16 = 4.00
From top to bottom, write the integer parts of the results to the fractional part of the number in base 16.
(0.25)10 = (0.4)16
OVERALL RESULT
Combine the whole number and fractional parts to obtain the overall result.
(125.25)10 = (7D)16 + (0.4)16 = (7D.4)16
Complements are used in the digital computers in order to simplify the subtraction operation and for the logical manipulations. For each radix-r system (radix r represents base of number system) there are two types of complements.
n’s complement(Radix Complement)
(n-1)’s complement(Diminished Radix Complement)
The mostly used complements are 1's, 2's, 9's, and 10's complement. Apart from these complements, there are many more complements from which mostly peoples are not familiar. For finding the subtraction of the number base system, the complements are used. If r is the base of the number system, then there are two types of complements that are possible, i.e., r's and (r-1)'s. We can find the r's complement, and (r-1)'s complement of the number, here r is the radix. The r's complement is also known as Radix complement (r-1)'s complement, is known as Diminished Radix complement.
If the base of the number is 2, then we can find 1's and 2's complement of the number. Similarly, if the number is the octal number, then we can find 7's and 8's complement of the number.
Methods to Calculate Complement of a number
Method 1: To calculate r’s and (r-1)’s complement-
Formula to calculate r' s complement=(𝑟𝑛 )10 -x Formula to calculate (r-1)' s complement={((𝑟𝑛 )10-1}-x
Where r= radix/base of the number, n= number of digits in given number, X is the given number.
Let’s understand this with an example-
Eg. Find 10’s complement and 9’s complement of (638)10
Using formula- Here, n=10, k=3,x=638
10’s complement = (10*10*10)-638=1000-638= 362 9’s complement= 10’s complement -1=361
Note- 𝑛^𝑘 is always in decimal number system. So, to use this formula with other number system first convert that number system to decimal number system and then perform the S.N. Complement Description
1
Radix Complement
The radix complement is referred to as the r's complement
2
Diminished Radix Complement
The diminished radix complement is referred to as the (r-1)'s complement
arithmetic operations.
Example 1: (1011000)2
This number has a base of 2, which means it is a binary number. So, for the binary numbers, the value of r is 2, and r-1 is 2-1=1. So, we can calculate the 1's and 2's complement of the number.
1's complement of the number 1011000 is calculated as:
={(27 )10-1}-(1011000)2
={(128)10-1}-(1011000)2
={(127)10}-(1011000)2
=11111112-10110002
=0100111
2's complement of the number 1011000 is calculated as:
=(27 )10-(1011000)2
=(128)10-(1011000)2
=100000002-10110002
=01010002
Example 2: (155)10
This number has a base of 10, which means it is a decimal number. So, for the decimal numbers, the value of r is 10, and r-1 is 10-1=9. So, we can calculate the 10's and 9's complement of the number.
9's complement of the number 155 is calculated as:
={(103 )10-1}-(155)10
=(1000-1)-155
=999-155
=(844)10
10's complement of the number 1011000 is calculated as:
=(103 )10-(15510
=1000-155
=(845)10
Example 3: (172)8
This number has a base of 8, which means it is an octal number. So, for the octal numbers, the value of r is 8, and r-1 is 8-1=7. So, we can calculate the 8's and 7's complement of the number.
7's complement of the number 172 is calculated as:
={(83 )10-1}-(172)8
=((512)10-1)-(132)8
=(511)10-(122)10
=(389)10
=(605)8
8's complement of the number 172 is calculated as:
Poornima College of Enginnering Unit-II (Number System)
Subject Teacher: Bhagirath Singh Chauhan #9829275869 Page: 8
=(83 )10-(172)8
=(512)10-1728
=51210-12210
=39010
=6068
Example 4: (F9)16
This number has a base of 16, which means it is a hexadecimal number. So, for the hexadecimal numbers, the value of r is 16, and r-1 is 16-1=15. So, we can calculate the 16's and 15's complement of the number.
15's complement of the number F9 is calculated as:
{(162 )10-1}-(F9)16 (256-1)10-F916 25510-24910
(6)10
(6)16
16's complement of the number F9 is calculated as:
{(162 )10 }-(F9)16
25610-24910
(7)10
(7)16
Poornima College of Engineering Number System
Subject Teacher: Bhagirath Singh Chauhan # 9829275869 Page No.: 9
Method 2- To calculate r’s and (r-1)’s complement-
Steps to find (r-1)’s complement:
To find (r-1)’s complement, subtract given number from largest number in that number system.
Lets us demonstrate this with an example-
Let us assume that you have to find r’ complement and (r-1)’s complement of number
(525)8 .
First find (r-1)’s complement, here first you find 7’s complement. As you know three digit largest number in octal number system is 777. So you are supposed to subtract 525 from 777.
(777-525)=252
So, (252)8 is the 7’s complement of given number.
Steps to find (r)’s complement:
To find r’s complement just add 1 to the (r-1)’s complement. So, 8’s complement of the given number is (252+1) i.e. (253)8
The binary addition & subtraction is similar to the decimal number system. But the main difference between these two is, binary number system uses two digits like 0 & 1 whereas the decimal number system uses digits from 0 to 9 and the base of this is 10. There are some specific rules for the binary system. Like when we add & subtract binary numbers then we must be very careful while carrying otherwise borrowing digits because these will occur more frequently.
For understanding, the binary addition first considers the addition of two decimal numbers as shown below.
When we added the one’s column of the binary digit (i.e., 7+4) we get the number which is greater than the base of the decimal number (the base of the number is 10 and the sum of the digit is 11). Now add the tens column of the binary digit whose sum is equal to 9, and hence less than the base. So there is no carry in the ten’s column of the binary digit.
The solution of the above sum is explained below.
Binary Addition
The binary number system uses only two digits 0 and 1 due to which their addition is simple. There are four basic operations for binary addition, as mentioned above.
0+0=0
0+1=1
1+0=1
1+1=10
The above first three equations are very identical to the binary digit number. The column by column addition of binary is applied below in details. Let us consider the addition of 11101 and 11011.
The above sum is carried out by following step
1 + 1 = 10 = 0 with a carry of 1.
1+0+1 = 10 = 0 with a carry of 1
1+1+0 = 10 = 10 = 0 with a carry of 1
1+1+1= 10+1 = 11= 1 with a carry of 1
1 +1 +1 = 11
Note carefully that 10 + 1 = 11, which is equivalent to two + one = three (the next binary number after 10)
Thus the required result is 111000.
Binary Subtraction
The subtraction of the binary digit depends on the four basic operations 0 – 0 = 0
1 – 0 = 1
1 – 1 = 0
10 – 1 = 1
The above first three operations are easy to understand as they are identical to decimal subtraction. The fourth operation can be understood with the logic two minus one is one.
For a binary number with two or more digits, the subtraction is carried out column by column as in decimal subtraction. Also, sometimes one has to borrow from the next higher column. Consider the following example.
The above subtraction is carried out through the following steps. 0 – 0 = 0
For 0 – 1 = 1, taking borrow 1 and then 10 – 1 = 1
For 1 – 0, since 1 has already been given, it becomes 0 – 0 = 0
1 – 1 = 0
Therefore the result is 0010.