Subtraction of Unsigned Numbers
The direct method of subtraction taught in elementary schools uses the borrow concept. In this method we borrow a 1 from a higher significant position when the minuend digit is smaller than the corresponding subtrahend digit. This seems to be easiest when people perform subtraction with paper and pencil. When subtraction is implemented with digital hardware, this method is found to be less efficient than the method that uses complements.
The subtraction of two n-digit unsigned numbers M - N (N * 0) in base r can be done as follows:
1. Add the minuend M to the r's complement of the subtrahend N. This performs M + (r' - N) = M - N + r'.
2. If M "" N, the sum will produce an end carry r' which is discarded, and what is left is the result M - N.
3. If M < N, the sum does not produce an end carry and is equal to r' - (N - M), which is the r's complement of (N - M). To obtain the answer in a familiar form, take the r' s complement of the sum and place a negative sign in front.
Consider, for example, the subtraction 72532 - 13250 = 59282. The lO's complement of 13250 is 86750. Therefore:
M = 72532
lO's complement of N = +86750
Sum = 159282
Discard end carry 10' = -100000
Answer = 59282
Now consider an example with M < N. The subtraction 13250 - 72532 produces negative 59282. Using the procedure with complements, we have
M = 13250
lO's complement of N = +27468
Sum = 40718
There is no end carry.
Answer is negative 59282 = 10's complement of 40718