Binary Arithmetic.ppt
《Binary Arithmetic.ppt》由会员分享,可在线阅读,更多相关《Binary Arithmetic.ppt(39页珍藏版)》请在麦多课文档分享上搜索。
1、1,Binary Arithmetic,Binary addition Binary subtraction Binary multiplication Binary division,2,Complements of Binary Numbers,1s complements 2s complements,3,Complements of Binary Numbers,1s complement Change all 1s to 0s and all 0s to 1s,1 0 1 0 1 0 1 0,0 1 0 1 0 1 0 1,4,Complements of Binary Number
2、s,2s complement Find 1s complement and then add 1,1 0 1 0 1 0 1 0,0 1 0 1 0 1 0 1,Input bits Adder Output bits (sum),Carry In,(add 1),1,0 1 0 1 0 1 1 0,2s complement,1s complement,5,Signed Numbers,6,Topics for Signed Numbers,Signed-magnitude form 1s and 2s complement form Decimal value of signed num
3、bers (How to convert) Range of values (max and min) Floating-point numbers,7,Signed Numbers,Signed-magnitude form The sign bit is the left-most bit in a signed binary number A 0 sign bit indicates a positive magnitude A 1 sign bit indicates a negative magnitude,8,Signed Numbers,1s complement form A
4、negative value is the 1s complement of the corresponding positive value 2s complement form A negative value is the 2s complement of the corresponding positive value,9,Signed Numbers,Decimal value of signed numbers Sign-magnitude 1s complement 2s complement,10,Signed Numbers,Range of ValuesTotal comb
5、inations = 2n 2s complement form: (2n 1) to + (2n 1 1),Range for 8 bit number: n = 8 -(28-1) = -27 = -128 minimum +(28-1) 1 = +27 - 1 = +127 maximum Total combination of numbers is 28 = 256.,11,Signed Numbers,Range for 16 bit number: n = 16 -(216-1) = -215 = -32768 minimum +(216-1) - 1 = +215 = +327
6、67 maximum Total combinations is 216 = 65536 (64K),8 bit examples:10000000 =,-128,11111111 =,-1,10000001 =,-127,01111111 =,+127,12,Signed Numbers,Floating-point numbers Can represent very large or very small numbers based on scientific notation. Binary point “floats”. Two Parts Mantissa represents m
7、agnitude of number Exponent represents number of places that binary point is to be moved Three forms Single-precision (32 bits) float Double-precision (64 bits) double Extended-precision (80 bits) long double Also have Quadruple and Quadruple extended!,13,Single Precision,IEEE 754 standard Mantissa
8、(F) has hidden bit so actually has 24 bits. Gives 7 significant figures. 1st bit in mantissa is always a one Exponent (E) is biased by 127 called Excess-127 Notation Add 127 to exponent so easier to compare Range of exponents is -126 to +128 Sign (S) bit tells whether number is negative or positive,
9、S Exponent (E) Mantissa (fraction, F),32 bits,1 bit 8 bits 23 bits,14,Single Precision,Example: Convert 577710 to Floating Point 1st, convert to binary using divide by 2 method,577710 = 10110100100012 Positive number, so sign bit (S) equals 0.,2nd, count number of places to move binary point10110100
10、100012 = 1.011010010001 x 212Add 127 to 12 = 13910 = 100010112,Mantissa is fractional part, 011010010001 Finally, put everything together,15,Special Cases,Zero and infinity are special cases Can have +0 or -0 depending on sign bit Can also have + or - Not a Number (NaN) if underflow or overflow,16,E
11、xamples,17,Double Precision,Exponent has 11 bits so uses Excess-1023 Notation Mantissa has 53 bits (one hidden) 53 bits gives 16 significant figures,18,Arithmetic Operations with Signed Numbers,Addition Subtraction Multiplication Division,19,Arithmetic Operations with Signed Numbers,Addition of Sign
12、ed Numbers The parts of an addition function are: Augend - The first number Addend - The second number Sum - The result,Numbers are always added two at a time.,20,Arithmetic Operations with Signed Numbers,Four conditions for adding numbers:1. Both numbers are positive.2. A positive number that is la
13、rger than a negative number.3. A negative number that is larger than a positive number.4. Both numbers are negative.,21,Arithmetic Operations with Signed Numbers,Signs for Addition When both numbers are positive, the sum is positive. When the larger number is positive and the smaller is negative, th
14、e sum is positive. The carry is discarded.,22,Arithmetic Operations with Signed Numbers,Signs for Addition When the larger number is negative and the smaller is positive, the sum is negative (2s complement form). When both numbers are negative, the sum is negative (2s complement form). The carry bit
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- BINARYARITHMETICPPT
