You are on page 1of 20

Module – 4

Addition and subtraction using 2scomplement

1
Binary Addition
Binary Addition:
The rules of binary addition are:
0 + 0 = 0 (carry 0, sum 0)
0 + 1 = 1 (carry 0, sum 1)
1 + 0 = 1 (carry 0, sum 1)
1 + 1 = 0 (carry 1, sum 0)

Ex. 1 + 1 + 1 Ex. 1 + 0 + 1 Ex. 0 + 1 + 1

C S C S C S
1 + 1 = 1 0 0 + 1 = 0 1 1 + 1 = 1 0

1 0 0 1 1 0
+ 1 + 1 + 0
------------ ------------ ------------
1 1 1 0 1 0
C S C S C S
2
Binary Addition

3
Binary Addition

Example 1: Perform addition of (11001100)2 and (11011010)2

1 0 1 1 0 0 0 ⟵ Carry
1 1 0 0 1 1 0 0
1 1 0 1 1 0 1 0
1 1 0 1 0 0 1 1 0

Example 2: Add (28)10 and (15)10 by converting them into binary.


1 1 1 0 0⟵ Carry
(28)10 = 1 1 1 0 0
(15)10 = 0 1 1 1 1
1 0 1 0 1 1

4
Binary Addition
Calculate using binary addition:

(a) 111 + 100 = (b) 101 + 110 = (c) 1111 + 111

10 0 ------- carry 10 0 ------- carry 1 1 1 1 ---- carry


1 1 1 1 0 1 1 1 1 1
+1 0 0 +1 1 0 + 0 1 1 1
---------------- ---------------- ----------------
1 0 1 1 ------- sum 1 0 1 1 ------- sum 1 0 1 1 0 ---- sum

5
Binary Addition
Calculate using binary addition:

(a) 11101111 + 10101010 = (b) 1111111 + 10111 =

11 1 0 1 1 1 0 ------- carry
1 1 1 1 1 1 1 ------- carry
1 1 1 0 1 1 1 1
+1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1
------------------------------- + 1 0 1 1 1
-------------------------------
1 1 0 0 0 1 0 0 1 ------- sum
1 0 0 0 1 0 1 1 0 ------- sum

6
Binary Subtraction
Binary Subtraction:
The rules of binary subtraction are:
0–0=0
1–0=1
1–1=0
0 – 1 = 1 (Taking barrow from outside)

7
Complement of binary numbers
• Types of complement
• One’s (1’s) Complement
• Obtained by changing all 0’s to 1’s and all 1’s to 0’s.
• Ex. 1’s complement of 10101101 = 01010010
• Two’s (2’s) Complement
• Obtained by adding 1 to LSB (least significant bit) of 1’s
complement of a number.
• Ex. Given

8
Binary Subtraction
Binary Subtraction Using 1’s Complement:
• Take 1’s complement of subtrahend and add it to minuend.
• If carry is generated, then result is positive. Add carry to the result to get
final result.
• If carry is not generated, then result is negative. Take 1’s complement of
the result and place a negative sign in front .

9
Binary Subtraction
Example 1: Perform (28)10 – (19)10 using 1’s complement.

Example 2: Perform (15)10 – (28)10 using 1’s complement.

10
Binary Subtraction
Binary Subtraction Using 2’s Complement:
• Take 2’s complement of subtrahend and add it to minuend.
• If carry is generated, then result is positive, discard carry
• If carry is not generated, then result is negative. Take 2’s complement of
the result and place a negative sign in front .

Example 1: Perform (28)10 – (19)10 using 2’s complement.

11
Binary Subtraction
Example 2: Perform (15)10 – (28)10 using 2’s complement.

12
13
14
Subtraction using 9’s Complement
• Take 9’s complement of subtrahend and
add it to minuend.
• If carry is generated, then result is
positive. Add carry to the result to get final
result.
• If carry is not generated, then result is
negative. Take 9’s complement of the
result and place a negative sign in front.

15
Example 1: Perform (72532)10 – (3250)10 using
9’s complement.
Solution:
• 9’s complement of 03250: 96749
72532 Minuend
+96749 9’s complement
1 69281
+ 1
Ans:69282
16
Example 2: Perform (3250)10 – (72532)10 using
9’s complement.
Solution:
• 9’s complement of 72532: 27467
03250 Minuend
+27467 9’s complement
30717
No carry
9’s complement of 30717: -69282
17
Subtraction using 10’s Complement
• Take 10’s complement of subtrahend and
add it to minuend.
• If carry is generated, discard it. The result
is positive.
• If carry is not generated, then result is
negative. Take 10’s complement of the
result and place a negative sign in front.

18
Example 1: Perform (72532)10 – (3250)10 using
10’s complement.
Solution:
• 10’s complement of 03250: 96749+1=96750
72532 Minuend
96750 10’s complement
1 69282
Discard carry
Answer: 69282
19
Example 2: Perform (3250)10 – (72532)10 using
10’s complement.
Solution:
• 10’s complement of 72532: 27468
03250 Minuend
27468 10’s complement
30718
No carry
10’s complement of 30718: -69282
20

You might also like