1. 1’s and 2’s Complement
subtraction
Rashmi Patil
2. 1’s Complement
• To get 1’s complement of a binary number,
simply invert the given number.
• Complement of 1 is 0 and 0 is 1
• Example, 1’s complement of binary number
110010 is 001101.
3. Examples of 1’s Complement
• Example-1: Find 1’s complement of binary
number 10101110.
Ans: 01010001.
• Example-2: Find 1’s complement of binary
number 10001.001.
Ans: 01110.110.
5. 1’s Complementation in Signed Binary number
Representation
• 1’s complement binary numbers are very useful in Signed
number representation.
• Positive numbers are simply represented as Binary number
number.
• There is nothing to do for positive binary number.
• But in case of negative binary number representation, we
represent in 1’s complement.
• If the number is negative then it is represented using 1’s
complement. First represent the number with positive sign
and then take 1’s complement of that number.
7. Subtractions by 1’s Complement
• The algorithm to subtract two binary number using 1’s
complement is explained as following below:
• Take 1’s complement of the subtrahend
• Add with minuend
• If the result of above addition has carry bit 1, then add it to
the least significant bit (LSB) of given result. Result is positive.
• If there is no carry bit 1, then take 1’s complement of the
result which will be negative
8. Subtractions by 1’s Complement
Example 1: 10101 - 00111
• We take 1's complement of subtrahend
00111, which comes out 11000. Now, sum
them. So,
• 10101+11000 =1 01101.
• In the above result, we get the carry bit 1, so
add this to the LSB of a given result, i.e.,
01101+1=01110, which is the answer.
.
9. Subtractions by 1’s Complement
Example 2: 10101 - 10111
• We take 1's complement of subtrahend
10111, which comes out 01000. Now, add
both of the numbers. So,
• 10101+01000 =11101.
• In the above result, we didn't get the carry bit.
So calculate the 1's complement of the result,
i.e., 00010, which is the negative number and
the final answer
10. 2's Complement of a Binary Number
• There is a simple algorithm to convert a binary
number into 2's complement.
• To get 2's complement of a binary number,
simply invert (take 1’s Complement of )the
given number and add 1 to the least
significant bit (LSB) of given result.
11. The Basic Strategy of Performing Subtraction by
Preserving Addition:
1. Represent both values as positive signed numbers;
2. Decide the minimum bit length required.
3. Convert the subtrahand (quantity to be subtracted)
into its negative representation using either of the
two methods of 2's complement convertion
discussed previously.
4. Then add the two values together.
13. Example
Ex: perform (5)10-(4)10 using 2’s complement
Ans:
1. 510 converts to 0101 (at least a 4-bit pattern including the + sign is
required at the outset)
2. and,410 converts to 0100.
3. so -410 must be 1100 (after converting the +ive number to its -
tive complement)
4. Carry is generated answer is positive . Discard it. Hence Answer
is (0001)2=(+1)10