Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 11

Adder-Subtractor

CIRCUIT & FUNCTION


2’s complement
4-bit binary Adder-Subtractor

2
Recall the function of XOR Gate
• Expression: Y = A ⨁ B
(where Y = o/p, A & B are i/ps)

• Truth Table: Inputs Output


A B Y
0 0 0
0 1 1
1 0 1
1 1 0
• Symbol:
Inputs Input
Output Y

4
Analyzing the function of XOR Gate other
way
• If one input has logic 0, then whatever is
applied on other input that is produced on
output.

• If one input has logic 1, then whatever is


applied on other input invert of that is
produced on output
Methods to deal with Signed Numbers
• Sign & Magnitude Method
• 2’s Complement Method
• In Sign & Magnitude Method binary numbers are
written in such a manner that the left most bit
represents the Sign of the number while other bits
represent the Magnitude of the number, for eg +5 =
0101 & -5 = 1101
Here, left most bit (Blue Colour) is showing sign and
bits with Red colour are showing magnitude. + is
represented by 0 and – with 1.
Methods to deal with Signed Numbers

• In 2’s Complement Method +ve numbers are


represented in the same manner as in Sign &
Magnitude method but –ve numbers are
represented in a very different way.
• Taking 2’s Comp of a number means changing
the sign of the number, for eg we take a
number +5, i.e 0101 (in binary) and take its 2’s
comp then as a result we get -5.
2’s Complement Method contd.
• Method:
• Formula of 2’s Comp;
• 2’s Comp of a number = 1’s Comp of the
number + 1
• If we represent 2’s comp by A’ then;
• A’ = /A + 1
• Here A is the actual number
2’s Complement Method contd.
• Examples;
• A = +4 = 0100
• As we know A’ = /A + 1
• So, 1’s Comp = /A = 1011
+1
_____
Thus the answer is = A’ = 1100 = -4
Binary Addition & Subtraction by
2’s complement Method
• Examples:
• Let a no A = +7= 0111
• Let another no B = +4 = 0100
• Example 1: Addition: A + B
• +7+ 4 = +11 = 01011
• Example 2: Subtraction: A - B = A + (-B) = A + B’ (2’s Cmp)
• +7 – 4 = +3 = +7 +(-4) = +3 = 00011
Binary Addition & Subtraction by
2’s complement Method
• Example 3: Subtraction: A - B = A + (-B) = A + B’
• Let a number = A = +4 = 0100
• And another number = B = +7 = 0111
• Taking 2’s Comp of +7 = -7;
• As B = 0111 => /B = 1000 => B’ = /B + 1 = 1000 + 1 = 1001
• Now A - B = +4 -7 = +4 + (-7) = -3
0100
+1001
_____
Thus the answer is -3 = 1101
Verification of answer: As here A = -3 = 1101
Taking 2’s Comp of -3 as A = /A + 1 = 0010 + 1 = 0011 = +3
Hence proved

You might also like