Contents
• Unsigned binaryAddition with examples
• Unsigned decimal addition with examples
• Unsigned binary subtraction using 1’s and 2’s complement with
examples
• Unsigned decimal subtraction using 9’s and 10’s complement with
examples
3.
Unsigned addition
1) Binaryaddition:
The binary number system has two bits 0 and 1 only, therefore, the
possible binary additions are:
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0 with a carry of 1
• Decimal addition:
Example1: Add two decimal numbers
a) 356 and 482
Sol:
Carry
3 5 6
+ 4 8 2
b) 6543 and 743
Carry
6 5 4 3
+ 7 4 3
8
3
8
1
6
8
2
7
1
7.
Unsigned subtraction
Binary Subtractionusing 1’s Complement:
Step 1: Convert number to be subtracted to it’s 1’s complement form
Step 2: Perform the addition
Step 3: If the final carry is 1 then add it to the result obtained in step(2).If the final
carry is 0, result obtained in step(2) is negative and in the 1’s complement form.
A-B = A+(-B) 1’s Complement of B = (-B)
8.
Example 1:
• Subtractbinary two binary numbers using 1’s complement
a) (1100)2 – (0101)2
Sol: Let us consider, A = 1100 and B = 0101
Step(1): Convert B into 1’s complement of B
0101 (B) = 1010 (-B)
Step(2): Perform addition
A+(-B)= 1100 + 1010
1 1 0 0 (12)
+ 1 0 1 0 (-5)
1 0 1 1 0
Step(3): If final carry is 1 then add it to result obtained in step(2)
0 1 1 0
+ 1
0 1 1 1 (7)
Carry
Final answer
9.
Example:
• Subtract binarytwo binary numbers using 1’s complement
b) (0101)2 – (1100)2
Sol: Let us consider, A = 0101 and B = 1100
Step(1): Convert B into 1’s complement of B
1100 (B) = 0011 (-B)
Step(2): Perform addition
A+(-B)= 0101 + 0011
0 1 0 1 (05)10
+ 0 0 1 1 (-12)10
Step(3): If the final carry is 0, result obtained in step(2) is negative and in the 1’s complement form.
1 0 0 0 = Negative number and 1’s complement of 1000 is 0111
= 0111
= (-7)10
No Carry
Final answer
1
0
0
1 0
1
1
0
10.
Unsigned subtraction
Binary Subtractionusing 2’s Complement:
Step1: Find the 2’s complement of number to be subtracted.
Step2: Perform the addition
Step3: If the final carry is generated then the result is positive, and it is true form. If
the final carry is not produced, then the result is negative and in the 2’s
complement form.
A-B = A+(-B)
2’s Complement of B = (-B)
11.
Example 1:
• Subtracttwo binary numbers using 2’s complement
a) (1100)2 – (0101)2
Sol: Let us consider, A = 1100 and B = 0101
Step(1): Take 2’s complement of B
B= 0101
1 0 1 0
+ 1
1 0 1 1
1’s Complement
2’s Complement of B =(-B)
12.
Step (2): Performthe addition
A+(-B)
1 1 0 0
+ 1 0 1 1
1 0 1 1 1
Carry
Step (3) : In the above result, final carry is generated. Hence it is positive number and
the result is true form.(Ignore Carry)
Answer is 0111 = (7)10
13.
Example:
• Subtract binarytwo binary numbers using 2’s complement
a) (0101)2 – (1100)2
Sol: Let us consider, A = 0101 and B = 1100
Step(1): Take 2’s complement of B
B= 1100
0 0 1 1
+ 1
1’s Complement of B
2’s Complement of B =(-B)
Carry
1 0
1
0
1
0
14.
Step (2): Performthe addition
A+(-B)
0 1 0 1
+ 0 1 0 0
Step (3): In the above result final carry is not produced, then the result is negative
and in the 2’s complement form.
1001 is Negative number and 2’s complement of 1001 is
0 1 1 0
+ 1
0 1 1 1 = (-7)10
1
0
0
1
1
15.
Unsigned subtraction
Decimal Subtractionusing 9’s Complement:
Step1: Find the 9’s complement of number to be subtracted.
Step2: Perform the addition.
Step3: If the final carry is generated. Hence it is positive number and add the carry
to LSD of this result to get the answer. If the final carry is not produced, then the
result is negative and in the 9’s complement form.
A-B = A+(-B)
9’s Complement of B = (-B)
16.
Example 1:
• Subtractthe following decimal numbers using 9’s complement
a) (983)10 – (812)10
Sol: Let us consider, A = 983 and B= 812
Step(1): Take 9’s complement of B.
9 9 9
- 8 1 2
1 8 7
Step(2): Perform the addition
A+(-B)
9 8 3
+ 1 8 7
Carry 1 7 0
1
1
1
17.
Step(3): In theabove result, End around carry/final carry is generated. Hence it is
positive number and add the carry to LSD of this result to get the answer.
1 7 0
+ 1
1 7 1
18.
Example 2:
• Subtractthe following decimal numbers using 9’s complement
a) (812)10 – (983)10
Sol: Let us consider, A = 812 and B= 983
Step(1): Take 9’s complement of B.
9 9 9
- 9 8 3
0 1 6 = (-B)
Step(2): Perform the addition
A+(-B)
8 1 2
+ 0 1 6
8 2 8
19.
• Step (3): If the above result, final carry is not produced, then the result is
negative and in the 9’s complement form.
828 is Negative number and 9’s complement of 828 is
9 9 9
- 8 2 8
1 7 1
Therefore, Final answer is (-171)10
20.
Advantages and disadvantagesof 1’s and 2’s complement
1’s complement 2’s complement
Advantages: Advantages:
a) Easy to generate the complement a) Only one zero
b) Only one addition process b) Only one addition process
c) No end around carry
Disadvantages: Disadvantages:
a) Handling last carryout a) Harder to generate the complement
b) Two different 0’s
21.
Unsigned subtraction
Decimal Subtractionusing 10’s Complement:
Step1: Find 10’s complement of number to be subtracted.
Step2: Perform the addition
Step3: If the final carry is generated then the result is positive, and it is true form. If
the final carry is not produced, then the result is negative and in the 10’s
complement form.
A-B = A+(-B)
10’s Complement of B = (-B)
22.
• Subtract thefollowing decimal numbers using 10’s complement
a) (983)10 – (812)10
Sol: Let us consider, A = 983 and B= 812
Step(1): Take 10’s complement of B.
B= 812
9 9 9
- 8 1 2
1 8 7
+ 1
1 8 8
Example 1:
9’s complement of B
10’s complement of B
23.
• Step (2):Perform the Addition
A+(-B)
9 8 3
+ 1 8 8
• Step (3): In the above result, final carry is generated. Hence it is positive number
and the result is true form.(Ignore Carry)
Final answer is 171
Carry
Carry
1
7
1
1
1
1
24.
Example 2:
• Subtractthe following decimal numbers using 9’s complement
a) (812)10 – (983)10
Sol: Let us consider, A = 812 and B= 983
Step(1): Take 10’s complement of B.
9 9 9
- 9 8 3
0 1 6
+ 1
0 1 7
9’s complement
10’s complement
25.
• Step (2):Perform the Addition
A+(-B)
8 1 2(A)
+ 0 1 7 (-B)
8 2 9
• Step (3): If the above result, final carry is not produced, then the result is negative
and in the 10’s complement form.
829 is Negative number and 10’s complement of 829 is
9 9 9
- 8 2 9
1 7 0
+ 1
1 7 1
Therefore, Final answer is (-171)10