09.12.2012 Views

DIGITAL DESIGN

DIGITAL DESIGN

DIGITAL DESIGN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Section 2.5 Representation of Negative Numbers 31<br />

DO<br />

The signed-magnitude<br />

NOT<br />

system has an equal number of positive<br />

COPY<br />

and negative<br />

integers. An n-bit signed-magnitude integer lies within the range −(2<br />

DO NOT COPY<br />

DO NOT COPY<br />

DO NOT COPY<br />

DO NOT COPY<br />

DO NOT COPY<br />

DO NOT COPY<br />

DO NOT COPY<br />

DO NOT COPY<br />

n−1−1) through +(2n−1−1), and there are two possible representations of zero.<br />

Now suppose that we wanted to build a digital logic circuit that adds<br />

signed-magnitude numbers. The circuit must examine the signs of the addends<br />

to determine what to do with the magnitudes. If the signs are the same, it must<br />

add the magnitudes and give the result the same sign. If the signs are different, it<br />

must compare the magnitudes, subtract the smaller from the larger, and give the<br />

result the sign of the larger. All of these “ifs,” “adds,” “subtracts,” and “compares”<br />

translate into a lot of logic-circuit complexity. Adders for complement<br />

number systems are much simpler, as we’ll show next. Perhaps the one redeeming<br />

feature of a signed-magnitude system is that, once we know how to build a<br />

signed-magnitude adder, a signed-magnitude subtractor is almost trivial to<br />

build—it need only change the sign of the subtrahend and pass it along with the<br />

minuend to an adder.<br />

2.5.2 Complement Number Systems<br />

While the signed-magnitude system negates a number by changing its sign, a<br />

complement number system negates a number by taking its complement as<br />

defined by the system. Taking the complement is more difficult than changing<br />

the sign, but two numbers in a complement number system can be added or subtracted<br />

directly without the sign and magnitude checks required by the signedmagnitude<br />

system. We shall describe two complement number systems, called<br />

the “radix complement” and the “diminished radix-complement.”<br />

In any complement number system, we normally deal with a fixed number<br />

of digits, say n. (However, we can increase the number of digits by “sign extension”<br />

as shown in Exercise 2.23, and decrease the number by truncating highorder<br />

digits as shown in Exercise 2.24.) We further assume that the radix is r, and<br />

that numbers have the form<br />

D = dn–1dn–2···d1d0 .<br />

The radix point is on the right and so the number is an integer. If an operation<br />

produces a result that requires more than n digits, we throw away the extra highorder<br />

digit(s). If a number D is complemented twice, the result is D.<br />

2.5.3 Radix-Complement Representation<br />

In a radix-complement system, the complement of an n-digit number is obtained<br />

by subtracting it from r n . In the decimal number system, the radix complement<br />

is called the 10’s complement. Some examples using 4-digit decimal numbers<br />

(and subtraction from 10,000) are shown in Table 2-4.<br />

By definition, the radix complement of an n-digit number D is obtained by<br />

subtracting it from r n . If D is between 1 and rn signed-magnitude<br />

adder<br />

signed-magnitude<br />

subtractor<br />

complement number<br />

system<br />

radix-complement<br />

system<br />

10’s complement<br />

− 1, this subtraction produces<br />

Copyright © 1999 by John F. Wakerly Copying Prohibited

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!