Page 75 - Engineering Digital Design
P. 75
46 CHAPTER 2 / NUMBER SYSTEMS, BINARY ARITHMETIC, AND CODES
Algorithm 2.5: N rC <«- N r
Replace each digit a, in N r by (r — 1) — a/ and then add 1 to the LSD of the resultant
A simpler, "pencil-and-paper" method exists for the 2's complement of a number A^
and is expressed by Algorithm 2.6:
Algorithm 2.6: N^c *~ ^2
For any binary number A^ and beginning with the LSB, proceed toward the MSB until
the first 1 bit has been reached^ Retain that 1 bit and complement the remainder of the
bits toward and including the MSB.
With reference to Table 2.6, Eq. (2.12), and Algorithm 2.5 or 2.6, the following examples
of radix complement representation are provided:
EXAMPLE 2.15 The 10's complement of 47.83 is A^io + ILSD = 52.17.
EXAMPLE 2.16 The 2's complement of 0101101.101 is N 2 + ILSB = 1010010.011.
EXAMPLE 2.17 The 16's complement of A3D is N 16 + 1 LSD = 5C2 + 1 = 5C3.
The decimal value of Eq. (2.12) can be found from the polynomial expression as
n-2
= -(a a-ir tt tt --) + fl/r 1 (2.13)
for any n-digit number of radix r. In Eqs. (2.12) and (2.13) the MSD is taken to be the
position of the sign symbol.
2's Complement Representation The radix complement for binary is the 2's comple-
ment (2C) representation. In 2's complement the MSB is the sign bit, 1 indicating a negative
number and 0 a positive one. The decimal range of representation for n integer bits in 2's
l
n
complement is from —(2 ~') through +(2"~ — 1). From Eq. (2.12), the 2's complement is
formed by
N 2C = T - N 2 = N 2 + ILSB (2.14)
for any binary number A^ of n integer bits. Or by Algorithm 2.5, the 2's complement of
a binary number A^ is obtained by replacing each bit a, in A^ by (1 — a,) and adding 1
to the LSB of the result. The simpler pencil-and-paper method, often used to generate 2's
complement from a binary number N r, results from application of Algorithm 2.6. In this
case A^2 is the bit complement of the number as given in Table 2.6. A few examples of 8-bit
2's complement numbers are shown in Table 2.7. Notice that application of Eq. (2.14) or
Algorithm 2.6 changes the sign of the decimal value of a binary number (+ to — and vice
versa), and that only one zero representation exists.
Application of Eq. (2.13) gives the decimal value of any 2's complement number, in-
cluding those containing a radix point. For example, the pattern A^c. = 11010010.011 has