0% found this document useful (0 votes)
22 views26 pages

Arithmetic Operation Using Complement

Uploaded by

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

Arithmetic Operation Using Complement

Uploaded by

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

Digital Logic Design

Arithmetic Operations Using Complement


Complement in Binary Number
System

2
Complement in Binary Number
System

 There are two types of complements in binary


number system
1. 1’s complement
2. 2’s complement

3
1’s complement

 All bits are reversed in original number


 Example#1
Original Number: 101011
1’s complement of 101011 = 010100
 Example#2
Original Number: 1100110
1’s complement of 1100110 = 0011001

4
2’s complement

 Add 1 in 1’s complement


 Example#1
Original Number: 101011
1’s complement of 101011 = 010100
2’s complement of 101011 = 010100 + 1 = 010101
 Example#2
Original Number: 1100110
1’s complement of 1100110 = 0011001
2’s complement of 1100110 = 0011001 + 1 = 11010

5
Difference between 1’s and
2’s complement

6
Difference between 1’s and 2’s
complement
 1’s complement is calculated by reversing all
bits of given number
 If add 1 into 1’s complement, then 2’s
complement will be calculated
 If subtract 1 from 2’s complement, then 1’s
complement will be calculated from 2’s
complement.

7
Calculation of 1’s
complement from 2’s
complement

8
Calculation of 1’s complement from 2’s
complement

 Subtract 1 from 2’s complement to get 1’s


complement. 780 – 1 =
 Example#1
2’s complement of 1100110 = 11010
1’s complement of 1100110 = 11010 – 1 = 11001
 Example#2
2’s complement of 1011 = 0101
1’s complement of 1011 = 101 – 1 = 100

9
Calculation of 2’s
complement without 1’s
complement

10
Calculation of 2’s complement without 1’s
complement
 Leave 1st non-zero Least Significant Bits
(LSB) as it is and reverse all remaining bits
 Example#1
2’s complement of 1100110 = 0011010
 Example#2
2’s complement of 1011 = 0101

11
Importance of Complements

12
Importance of Complements
 Almost all computer-operation are based on
arithmetic operations.
 There are four basic arithmetic operations.
1. Addition
2. Subtraction
3. Multiplication
4. Division
 Computer can do all arithmetic operations by
using only addition. This can only be done by
using complements.

13
Arithmetic Operations

14
Arithmetic Operations

 There are four basic arithmetic operations.


1. Addition
2. Subtraction
3. Multiplication
4. Division

15
Arithmetic Operations
(Addition)

16
Addition
 Add bits of given numbers and add carry to
next Most Significant Bit (MSB) if it exists.
 Example#1: addition of 1010 and 1010

1010
1010
10100

17
Addition
 Example#2: addition of 1110 and 1010

1110
1010
11000

18
Addition
 Example#3: addition of 1110, 1010 and 1100

1110 1110
1010 1010
11000 1100
1100 100100
100100

19
Arithmetic Operations
(Subtraction)

20
Subtraction using 2’s complement
 Example#1: Subtraction between of 1011 and 101

1001 1001 1001


-101 -0101 +1011
10100

Answer: 100

21
Subtraction using 2’s complement
 Example#1: Subtraction between of 1011 and 101

101 0101 0101


-1001 -1001 +0111
1100

Answer: -100

22
Arithmetic Operations
(Multiplication)

23
Multiplication
 Multiplication of 1011 and 101

1001
1001
101
101
1001
00000
100100
101101

Answer: 101101
24
Arithmetic Operations
(Division)

25
Division

26

You might also like