$\require{cancel}$
Digit | 9's Compliment |
---|---|
0 | 9 |
1 | 8 |
2 | 7 |
3 | 6 |
4 | 5 |
5 | 4 |
6 | 3 |
7 | 2 |
8 | 1 |
9 | 0 |
999 -354 ==== 645
Form the 9's complement of the second number Add the two numbers If there is a carry out Add it to the LSB of the sum Else The result is negative, find the 9's complement of the sum and add a - sign
9 - 3 => 9 + 6 = 15 => 6 5 - 6 => 5 + 3 => 08 => -1 The 9's complement of 8 is 1 7 - 7 => 7 + 2 = 09 => 0 521 => 521 521 => 521 - 167 +832 -634 +365 ---- ---- 1353 => 354 0886 => (-) 113
200 => 200 => 200 - 1 -001 +998 ---- 1198 => 199
If the carry out is 0, the sum is negative, take the 10's complement. Otherwise the result is fine
125 => 874 + 1 => 875 Test 125 +875 ---- 1000 => 000 5298 => 4701 + 1 => 4702 Test 5298 +4702 ----- 10000
269 269 - 128 => 871+1 => +872 --- 1141 => 141 3421 => => 3421 - 4237 5762+1 +5763 ----- 9184 => 0815+1 => -816