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.4 Addition and Subtraction of Nondecimal Numbers 29<br />

DO NOT COPY<br />

1 1 1 1 1 1 1<br />

X 190 1 0 1 1 1 1 1 0<br />

X 173 1 0 1 0 1 1 0 1<br />

Y + 141 + 1 0 0 0 1 1 0 1<br />

Y + 44 + 0 0 1 0 1 1 0 0<br />

X + Y 331 1 0 1 0 0 1 0 1 1 X + Y 217 1 1 0 1 1 0 0 1<br />

DO<br />

Figure 2-1<br />

NOT COPY<br />

Examples of decimal and corresponding binary additions.<br />

examples from the figure are repeated below along with two more, this time<br />

showing the borrows as a bit string B:<br />

DO NOT COPY<br />

B<br />

001111100<br />

B<br />

011011010<br />

X 229 11100101<br />

X 210 11010010<br />

Y − 46 − 00101110<br />

Y −109 − 01101101<br />

DO<br />

X − Y 183 10110111<br />

NOT<br />

X − Y 101<br />

COPY<br />

01100101<br />

B<br />

010101010<br />

B<br />

000000000<br />

X 170 10101010<br />

X 221 11011101<br />

Y − 85 − 01010101<br />

Y − 76 − 01001100<br />

DO NOT COPY<br />

X − Y 85 01010101 X − Y 145 10010001<br />

A very common use of subtraction in computers is to compare two numbers. For comparing numbers<br />

example, if the operation X − Y produces a borrow out of the most significant bit<br />

position, then X is less than Y; otherwise, X is greater than or equal to Y. The relationship<br />

DO<br />

between carries and<br />

NOT<br />

borrow in adders and subtractors<br />

COPY<br />

will be explored<br />

in Section 5.10.<br />

Addition and subtraction tables can be developed for octal and hexadecimal<br />

digits, or any other desired radix. However, few computer engineers bother<br />

to memorize these tables. If you rarely need to manipulate nondecimal numbers,<br />

DO NOT COPY<br />

Must borrow 1, yielding<br />

the new subtraction 10–1 = 1<br />

Figure 2-2<br />

Examples of decimal<br />

After the first borrow, the new<br />

DO<br />

subtraction<br />

NOT<br />

for this column is<br />

COPY<br />

and corresponding<br />

0–1, so we must borrow again.<br />

binary subtractions.<br />

The borrow ripples through three columns<br />

to reach a borrowable 1, i.e.,<br />

100 = 011 (the modified bits)<br />

+ 1 (the borrow)<br />

DO NOT COPY<br />

0 10 1 1 10 10<br />

0 10 10 0 1 10 0 10<br />

minuend X 229 1 1 1 0 0 1 0 1<br />

X 210 1 1 0 1 0 0 1 0<br />

subtrahend Y – 46 – 0 0 1 0 1 1 1 0<br />

Y – 109 – 0 1 1 0 1 1 0 1<br />

difference X – Y 183 1 0 1 1 0 1 1 1 X – Y 101 0 1 1 0 0 1 0 1<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!