[go: up one dir, main page]

0% found this document useful (0 votes)
16 views6 pages

Complements 1

Uploaded by

dilsadansri0812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

Complements 1

Uploaded by

dilsadansri0812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Complements are used in digital computer for simplifying the subtraction

operation and logical manipulation. There are two types of compliments for
each base r system. The r’s complement and (r-1)’s complement.

(r-1)’s complement:- (r-1)’s complement of a number N is defined as (rn-


1)-N where r is radix(base) of number n is the number of digits in a number
N.

r's complement:- The r’s complement of a number N is defined as rn-N for


N≠0 and for N=0 it is 0. r's complement may also be obtained by adding 1
to (r-1)’s complement.

1’s complement:- In Binary number radix or base =2, & r-1 i.e. (2-1)=1, so
1’s complement of a number N is : (rn-1)-N

In binary number 2n is represented by a binary number that consist of


1 followed by n 0’s. Again 2n – 1 is a binary number represented by n 1’s.

Ex:- if n=3
Then 23=[1000]2
& 2n-1 = 1000-1=111
If n=4
Then 24=[10000]2
& 2n-1 = 1000-1=1111
So the 1’s complement of a binary number is obtained by subtracting each
digit from 1. The subtraction of a binary digit from 1 causes the bit to
change from 0 to 1 or from 1 to 0.

Ex:- 1’s complement of [10101]2


Formula (2n-1)-N
Here, n=5, N=10101
So, (25-1)-10101
=(100000-1)-10101
=11111 – 10101
=(01010)2
2’s Complement:- In binary base is 2 so r’s i.e. 2’s complement is 2n-N.
Where n is total number of digits in a number N.
Ex:- 2’s complement of (11010)2
Formula 2n-N
Here, n=5 and N= 11010
So, 25-11010
=100000-11010
=00110
Note 1:- We can also obtain 2’s complement by adding 1 into 1’s complement:
Ex:- Number 1 1 01 0
1’s complement 0 0 10 1
+ 1
-----------------------
0 0 1 1 0
Note 2:- 2’s complement can also be formed by leaving all least significant
0’s and the first 1 unchanged and then replacing all 1’s by 0s and 0’s by 1
in all higher significant bit.
Ex:- Number (1 1 0 1 0 0)2
2’s complement (0 0 1 1 0 0)2
9’s Complement:- In decimal number system radix is 10, and [10-1=9],
so 9’s complement of a number N is (10 -1)-N. In decimal 10 represents a
n n

number that consists of a single 1 followed by n 0’s and 10n-1 is a number


represented by n 9’s.
Ex:- If n=4 then 104-1=10000-1=9999
So the 9’s complement of a decimal number is obtained by subtracting each
digits from 9.
Ex:- 9’s complement of 742100
Formula (10n -1)-N, Where n=6 and N=742100
→(10 -1)-742100
6

→(1000000-1)-1
→999999-742100
→257899
10’s Complement:- The 10’s complement of an n digit number N in base 10 is
defined as 10n-N for N≠0 and 0 for N=0. We can also obtain 10’s complement
by adding 1 to the 9’s complement.
10’s complement can also be formed by leaving all the least significant
0’s unchanged, subtracting the first non-zero least significant digit from
10, and then subtracting all higher significant digits from 9.
Ex:- 10’s complement of 74150
Formula (10n –N)
First method second method Third method
here n=5 and N=74150 7 4 1 5 0 9 9 9 9 9
10 -74150
5
2 5 8 5 0 - 7 4 1 5 0
100000-74150 ---------------
25850 2 5 8 4 9
+ 1
---------------
2 5 8 5 0

Binary Arithmetic:

Arithmetic operations on binary number are performed in a manner similar


to that done in decimal numbers.

Binary Addition:-
Let X represent single bit number either 0 or 1. Any Y represents another
single bit either 0 or 1. Therefore single bit binary addition is:

X Y Sum bit Carry bit 2 bit sum


0 0 0 0 00
0 1 1 0 01
1 0 1 0 01
1 1 0 1 10

Note:- In case where X=1 and Y=2 binary addition is consistent like decimal
number addition. The binary sum of two number should be equivalent to the
decimal sum obtained by adding the same two numbers in decimal for example:
(1)10 + (1)10 = (2)10
(1)2 + (1)2 = (2)10 or (10)2
Binary Subtraction:- Subtraction of 0 from a number does not change its
value, while subtracting 1 reduces its value by 1. Now in order to subtract
1 from 0 we must borrow a 1 from the next most significant bit. It is also
done like decimal arighmetic.
Let X represent a single bit number either 0 or 1 and Y be another single
bit number either 0 or 1 therefore
X Y X-Y
0 0 0
1 0 1
1 1 0
Binary Multiplication:- Procedure for multiplying binary numbers containing
any number of bits is exactly the same as that used for multiplying decimal
numbers. It begins with least significant bit of multiplier, we multiply
each bit of multiplicand one bit at a time and the results are written in a
line. The line of result is called partial product. This process repeated
for each bits in the multiplier at the same time shifting the next partial
product one position to the left. After the process has been completed for
each bit in the multiplier the result is added.
For Example:-
1 1 0 Multiplicand
1 0 1 Multiplier
1 0 0
0 0 0 Parital Product
1 1 0
1 1 1 0 0 Product

Binary Division:-
Binary division is as same as that of decimal division.
For Example:
110 11110 101
110
xx110
110
000
Arithmetic operation (Addition/Subtraction) on numbers:
We can perform these operations using following methods:-
1. Signed magnitude representation.
2. Signed 1’s complement
3. Signed 2’s complement
1. Signed magnitude representation:- Add 25 and -30 in binary using 7 bit
register. To do the arithmetic addition using one negative number we have
to check the magnitude of the number. The number having smaller magnitude
is then subtracted from the bigger number and then the sign of bigger number
is selected.
e.g.:- + 2 5 → 0 0 1 1 0 0 1
- 30 → 1 0 1 1 1 1 0
Sign Bit
Now Subtract 1 0 1 1 1 1 0
- 0 0 1 1 0 0 1
1 0 0 0 1 0 1 ➔ -5
2. Arithmetic subtraction suing 1’s complement:-
The subtraction can be easily done using 1’s complement of the subtractend
(including sign bit) and then adding both numbers including sign bit. If
carry of the most significant bit or sign bit is 1, then increment the result
by 1 and discard the carry over. If the result is in negative i.e. it is
in 1’s complement.
For example
1. Add -25 and +30
Here subtractend is 25 and its binary representation
25 = 0 0 1 1 0 0 1
and its 1’s complement is 1 1 0 0 1 1 0
+30= 0 0 1 1 1 1 0
Now add:
1 1 0 0 1 1 0
0 0 1 1 1 1 0
1 0 0 0 0 1 0 0
Here, the carry is 1 out of sign bit so, the result get increment by 1 and
this 1 is out of sign bit so this is discarded.

0 0 0 0 1 0 0
+ 1
0 0 0 0 1 0 1 ➔ +5 Ans
2. Add -25 and -30
+25= 0 0 1 1 0 0 1 → 1’s complements= 1 1 0 0 1 1 0
+30= 0 0 1 1 1 1 0 → 1’s complements= 1 1 0 0 0 0 1
Now add both the complements 1 1 0 0 0 1 1 1
Here 1 is overflow so 1 is added + 1
to the result 1 0 0 1 0 0 0
Here sign bit has 1. It means result is in 1’s
complement form and the result will be negative
so to find the answer we have
to complement the result. 0 1 1 0 1 1 1 → -55
3. Arithmentic operation using 2’s complement:-
4. The subtraction can easily done using the 2’s complement by taking
the 2’s complement of the subtractend (including sign bit) and then
adding both the numbers including sign bit and discard any carry out
of the sign bit position. If the result is negative it is in 2’s
complement.
For example :-
Add 25 and -30
+25 = 0 0 1 1 0 0 1
+30 = 0 0 1 1 1 1 0
2’s complement of +30 is 1 1 0 0 0 1 0
Now add +25 and 2’s complement of +30
1 1 0 0 0 1 0
0 0 1 1 0 0 1
1 1 1 1 0 1 1
Since sign bit has value 1. It means result is in 2’s complement. So we
have to convert it into general form. For this we will subtract 1 from the
result and then complement the result as given below:
1 1 1 1 0 1 1
-1
1 1 1 1 0 1 0
Now 1’s complement of result 0 0 0 0 1 0 1 → 5 Ans.

Floating point representation:-


Floating point numbers consists of two parts the first part of number is a
signed fixed point number which is termed as mantissa and the second part
specifies the decimal or binary point position and is termed as exponent.
The mantissa can be an integer or a fraction.
Note:- The position of decimal or binary point is assumed and it is not a
physical point.
For example a decimal +12.34 in typical floating point notation is:
0.1234 x 102 or 1234 x 10-2
Floating point numbers are often represented in normalized form. A
floating point number whose mantissa doesn't contain 0 as the most
significant bit (digit) of the number is considered to be in
normalized form.
For example 001100 is not in normalized form
now 01100 is in normalized form.
A floating point number + 1010.001 in 16 bit register can be
represented in the normalized form (assuming 10 bit for mantissa and
6 bit for exponent) as 1010001000 x 10-6

You might also like