Arithmetic Operation Using Complement
Arithmetic Operation Using Complement
2
Complement in Binary Number
System
3
1’s complement
4
2’s complement
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
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
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
Answer: 100
21
Subtraction using 2’s complement
Example#1: Subtraction between of 1011 and 101
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