Page 83 - Engineering Digital Design
P. 83
54 CHAPTER 2 / NUMBER SYSTEMS, BINARY ARITHMETIC, AND CODES
In this case, the difference 1:1010 is given in 2's complement. The answer in true form
is the 2's complement (negation) of this result given by 1:1010 -»• 0;0110 2 or 6\ Q
which is negative. Algorithm 2.9 summarizes the steps required for the 2's complement
subtraction.
Algorithm 2.9: {A 2 -f (-B 2) -» A 2 + B 2C] or {-A 2 + (~B 2) ~» A 2C + B 2C}
(1) Set n-bit operands A = a wa n_i • • • a\a§ and JS = b nb n-\ • < - b\b$, where the MSB a n
and b n are reserved as sign bits, initially both 0.
(2) Generate B 2C by applying Eq. (2.14).
(3) Add operands A 2 + B 2c according to Algorithm 2.8.
(4)If|A 2| > IB 21, then the sum (S 2>0) is the true value with the sign bit 0. If \A 2\ < |B 2 |,
then the sum (S < 0) is given in 2's complement with sign bit equal to 1.
(5) The true value of a 2's complement sum is obtained by negation, S 2c)ic-
(6) If A 2 and B 2 are both negative numbers, the sum (S 2c < 0) is obtained by steps (2),
(3),and<5).
2.9.3 One's Complement Subtraction
Somewhat less common is the 1's complement subtraction of two binary numbers. In this
case the subtrahend is converted to 1's complement by using Eq. (2.15) in the form N 2.
The result is then added to the minuend with the carry overflow carried-end-around and
added to the LSB. Clearly, this is a more complex process than that for 2's complement.
The following two examples illustrate the subtraction process:
EXAMPLE 2.25
A OillOl OillOl =+13 10
-B -o;om +1:1000 =-7 lft
H OiOlOl
OiOllO = +6 10
Sign Bit
Again, the minuend and subtrahend are interchanged for comparison purposes, yielding a
negative difference as follows:
EXAMPLE 2.26
A o;oin o;oin = +7 10
-B -oil 101 * +i;ooio =-is Ift
lilOOl
lilOOl = -6, 0
Sign Bit