I've been surfing the net to understand the 'method of complements'. The problem is that, different sites explaining certain aspects differently, for Ex:- Wiki. shows 9's complement subtraction by taking 9's complement of the minuend and adding that to the subtrahend and 10's complement subtraction by taking 10's complement of the subtrahend and adding that to the minuend. Other sites are applying both 9's and 10's complement to the subtrahend only.
Moreover, the methods (both 9's and 10's complements) are not working when both the operands are negative as shown below:-
The rules that I've understood so far:-
a) 9's comp: If there is a carry beyond the number of digits, add that to the addition result to get the final answer, if there is no carry, the answer is negative and we have to take 9's complement of the result to get the answer(and put a -ve sign).
b) 10's comp: If there is a carry beyond the number of digits, just discard that, if there is no carry, the answer is negative and we have to take 10's complement of the result to get the answer(and put a -ve sign).
Ex: -8-5 = (-8)+(-5) = -13
10's comp. of 8(2) + 10's comp. of 5(5) = 7 (no carry, answer will be negative)
-(10's comp. of 7) = -3 (but this should be -13).
Please explain were am I doing wrong and on which operand the complement should be applied? If it can be applied on any one of the operands and they have different methods, then please explain that too.
(Pardon my English, my mother-tongue is not English).
Moreover, the methods (both 9's and 10's complements) are not working when both the operands are negative as shown below:-
The rules that I've understood so far:-
a) 9's comp: If there is a carry beyond the number of digits, add that to the addition result to get the final answer, if there is no carry, the answer is negative and we have to take 9's complement of the result to get the answer(and put a -ve sign).
b) 10's comp: If there is a carry beyond the number of digits, just discard that, if there is no carry, the answer is negative and we have to take 10's complement of the result to get the answer(and put a -ve sign).
Ex: -8-5 = (-8)+(-5) = -13
10's comp. of 8(2) + 10's comp. of 5(5) = 7 (no carry, answer will be negative)
-(10's comp. of 7) = -3 (but this should be -13).
Please explain were am I doing wrong and on which operand the complement should be applied? If it can be applied on any one of the operands and they have different methods, then please explain that too.
(Pardon my English, my mother-tongue is not English).