正在加载图片...
Section2.4 Addition and Subtraction of Nondecimal Numbers 29 111 1 11 190 101110 173 10101101 y+141 +10001101 Y+44 +00101100 X+y331101001011 X+y217 11011001 Figure 2-1 Examples of decimal and corresponding binary additions examples from the figure are repeated below along with two more,this time showing the borrows as a bit string B: 001111100 011011010 229 11100101 210 11010010 -46 -00101110 Y -109 -01101101 X-Y 183 10110111 X-Y 101 01100101 B 010101010 B 000000000 X 170 10101010 X 221 11011101 -85 -01010101 -76 -01001100 X-Y 85 01010101 x-Y 145 10010001 A very common use of subtraction in computers is to compare two numbers.For omparing numbers example,if the e operation X -Y produces a borrow out of the most significant bit position.thenYis less than y:otherwise.is greater than or equal to y The rela- tionship between carries and borrow in adders and subtractors will be explored in Sec ion 5.10. Addition and subtraction tables can be developed for octal and hexadeci mal digits,or any other desired radix.However,few computer engineers bother to memorize these tables.Ifyou rarely need to manipulate nondecimal numbers Figure 2-2 Examples of decimal and corres binary subractions agtopelesteoUghhreecohum 1 (the 010111010 010100110010 minuend X229 X210 10/g0/0 subtrahend y=46 -001011 y-=109 -01101101 Y-) 183 101101 x-Y 101 01100101 Copyright 1999 by John F.Wakerly Copying ProhibitedSection 2.4 Addition and Subtraction of Nondecimal Numbers 29 DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY DO NOT COPY Copyright © 1999 by John F. Wakerly Copying Prohibited examples from the figure are repeated below along with two more, this time showing the borrows as a bit string B: A very common use of subtraction in computers is to compare two numbers. For example, if the operation X − Y produces a borrow out of the most significant bit position, then X is less than Y; otherwise, X is greater than or equal to Y. The rela￾tionship between carries and borrow in adders and subtractors will be explored in Section 5.10. Addition and subtraction tables can be developed for octal and hexadeci￾mal digits, or any other desired radix. However, few computer engineers bother to memorize these tables. If you rarely need to manipulate nondecimal numbers, B X Y 229 − 46 001111100 11100101 − 00101110 B X Y 210 −109 011011010 11010010 − 01101101 X − Y 183 10110111 X − Y 101 01100101 B X Y 170 − 85 010101010 10101010 − 01010101 B X Y 221 − 76 000000000 11011101 − 01001100 X − Y 85 01010101 X − Y 145 10010001 190 + 141 331 1 1 0 + 1 0 0 1 1111 1 11 1 0 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 X Y X + Y X Y X + Y 173 + 44 217 1 0 1 + 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 1 0 1 Figure 2-1 Examples of decimal and corresponding binary additions. 229 – 46 183 – 1 0 1 0 0 1 1 0 1 1 0 0 0 10 10 0 1 10 0 10 10 1 1 10 10 1 0 1 X Y X – Y X Y X – Y minuend subtrahend difference 210 – 109 101 – 0 0 1 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1 The borrow ripples through three columns to reach a borrowable 1, i.e., 100 = 011 (the modified bits) + 1 (the borrow) After the first borrow, the new subtraction for this column is 0–1, so we must borrow again. Must borrow 1, yielding the new subtraction 10–1 = 1 1001 1 1 0 1 1 1 11 10 1 Figure 2-2 Examples of decimal and corresponding binary subtractions. comparing numbers
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有