ImageVerifierCode 换一换
格式:PPT , 页数:46 ,大小:444KB ,
资源ID:8050903      下载积分:10 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.docduoduo.com/d-8050903.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录   微博登录 

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(二进制数的补码表示.ppt)为本站会员(tkhy51908)主动上传,道客多多仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知道客多多(发送邮件至docduoduo@163.com或直接QQ联系客服),我们立即给予删除!

二进制数的补码表示.ppt

1、class-exercises,1、1011100010112= 8= 16,2、 ( 156 )10 = ( )2 3、convert 0.3910 to a number in radix 2.The precision must achieve 10%。,ten minutes,class-exercises,1、1011100010112= 5613 8= B8B 16,2、 ( 156 )10 = ( 10011100 )2 3、将0.3910转换为二进制数,要求精度达到10%。0.01102,Review of the last lesson,Positional Number S

2、ystems MSD,LSD,MSB,LSB General Positional-Number-System Conversions A decimal fraction A number in Binary radix Binary addition and subtraction,Binary numbers with certain width ; The numbers always be set as 0.xxxxxxxx; We can take these numbers as integers for operations!,MSB/LSB,Unsigned number,O

3、perations for unsigned numbers,0+0=0 1+0=1 1+1=10,Addition,C: carry S: sum,Operations for unsigned numbers,Addition : Overflow ?,Wrong !,Right !,0A = 0 1A = A,Multiplication,Shift-add : use adders and shift-registers; The product width will be 2n !,Operations for unsigned numbers,New rule differ fro

4、m add Maybe get negative number,subtraction,Should use signed number to express positive and negative,Operations for unsigned numbers,Once the signed numbers be used , subtraction can be made by add !,Operations for unsigned numbers,Subtraction rule is not necessary !,2.5 Representation of Negative

5、Numbers (负数的表示),2.5.1 Signed-Magnitude Representation P34符号 数值表示法(原码) 2.5.2 Complement Number Systems P35(补码数制) 2.5.3 Radix-Complement Representation P36(基数补码表示法) 2.5.4 Twos-Complement Representation P37(二进制补码表示法) 2.6 Twos-Complement Addition and Subtraction P39(二进制补码的加减法)Table 2-6 P40(十进制数与4位二进制数对照

6、表)2.6.3 Overflow (溢出) P41,2.5.1 Signed-Magnitude Representation,a number consists of a magnitude and a symbol indicating whether the magnitude is positive or negative. MSB as the Sign bit (0 = plus, 1 = minus)最高有效位表示符号位( 0 = 正,1 = 负)01111111127 11111111127 0010111046 1010111046 000000000 100000000,2

7、.5.1 Signed-Magnitude Representation符号 数值表示法(原码) Two possible representations of Zero零有两种表示(+ 0、 0) 2. An n-bit signed-magnitude integer range is (n位二进制整数表示范围): ( 2n-1 1) + ( 2n-1 1) The signed-magnitude system has an equal number of positive and negative integers. P35,represent the result with 8-bi

8、t signed-magnitude integer! 110-110=?the signed-magnitude system negates a number by changing its sign .Complement Number Systemsit negates a number by taking its complement as definedby the system. P35,Have you calculated the result?,25310-17610= ? 10,Have you calculated the result?,25310-17610= 77

9、 1025310-17610+100010-100010= 77 10,whats the meaning of 1000?,103=999+1,25310+(99910-17610)+1-100010= 77 10,823,9s complement!(9的补码),Have you calculated the result?,17610-25310= -77 10?,已知是3位数,无符号数表示的范围是:0-999,共1000个!,0,1, ,498,499,500, 998,999,共1000个! -500,-499, -1,0,1 498,499,共1000个!500,501, 999,

10、0,1 498,499,共1000个!,Tens complement!(10进制补码),-499用10的补数表示为1000-499=501,999-499+1=501,-253用10的补数表示为:,747,176+747=923,923是谁的10进制补码表示?,-77,2.5.2,2.5.2 Complement Number Systems(补码数制)radix Complement (基数补码) 2. Diminished Radix Complement 基数减1补码 (反码) ,2.5.2 Complement Number Systems(补码数制) an n-bit number

11、 D D = dn1dn2 d1d0 .The radix point is on the right and so the number is an integer. If an operation produces a result that requires more than n digits, we throw away the extra highorder digit(s). If a number Dis complemented twice, the result isD. (P35),2.5.3 Radix-Complement Representation,The com

12、plement of an n-digit number is obtained by subtracting it from r n . rs complement= r n -D(n位数D的基数补码等于从 r n 中减去该数)Example : Table 2-4 P36,2.5.3 Radix-Complement Representation,2.5.3 Radix-Complement Representation,rs complement= r n -D,If D is between 1 and rn 1, this subtraction produces another n

13、umber between 1 and r n - 1. what is the result of the subtraction, If D is 0?,2.5.3 Radix-Complement Representation,rs complement= r n -D,If D is between 1 and rn 1, this subtraction produces another number between 1 and r n - 1. what is the result of the subtraction, If D is 0? 00000000 (n-bit) (p

14、ositive)there is only one representationof zero in a radix-complementsystem.,Diminished Radix Complement Representation 基数减1补码表示法(反码) The Diminished Radix Complement of an n-digit number is obtained by subtracting it from r n -1 n位数的反码等于从 r n 1 中减去该数 Example : Table 2-4 ,2-5 P.36,(r-1)s Complement =

15、 r n 1-D *2.5.6 (P38) there are two representations of zero, positive zero (00 00) andnegative zero (11 11).,2.5.3 Radix-Complement Representation,2.5.3 Radix-Complement Representation,Advantage,r n D= (r n -1)-D+1,This can be accomplished by complementing the individual digits of D,2.5.4 Twos Compl

16、ement Representation (二进制补码表示法) P37,Twos- Complement( 二进制补码的求取 ): MSB (the sign bit) : 1 =minus; 0=plus Weight of the MSB: -2n-1 3. The range of representable numbers is -(2 n-1) through +(2 n-1 -1).,Twos- Complement ( 二进制补码的求取 ),Example 1. Write the 8-bit twos-complement representation for the deci

17、mal number: -119.(若约定字长是一个字节,试求11910的补码表示。) +11910011101112,as formula(公式):2n-D= (2n-1-D)+128-1: 1 1 1 1 1 1 1 1 subtract(减去)+119; -0 1 1 1 0 1 1 11 0 0 01 0 0 0plus(加)1: + 111910: 1 0 0 0 1 0 0 12,Twos- Complement ( 二进制补码的求取 ),Example 1. Write the 8-bit twos-complement representation for the decima

18、l number: -119.(若约定字长是一个字节,试求11910的补码表示。) +11910011101112,,Twos- Complement ( 二进制补码的求取 ),Example 1. Write the 8-bit twos-complement representation for the decimal number: -119.(若约定字长是一个字节,试求11910的补码表示。) +11910011101112,,100010002 + 1100010012=-11910,带符号位一起按位取反再+1,得到相反数的补码.,Table 2-6 Decimal and 4-bi

19、t numbers (P40),Sum up for the Complement (总结),Positive number has the same: Sign-Magnitude,Ones Complement,and Twos- Complement ( 正数的原码、反码、补码相同),Sum up for the Complement (总结),Complement Number Systems,signed-magnitude system,010001,101111,(010001),(110001),+1710,-1710,Sum up for theComplement (总结)

20、,Complement Number Systems,signed-magnitude system,(010001),(101111),(010001),(110001),+1710,-1710,不变,+1710,-1710,符号位改变,符号位不变其 余按位取反加1.,连同符号位一起按位取反加1.,连同符号位一起按位取反加1.,符号位改变,Sign extension for a twos complement number (符号位扩展),We can convert an n-bit twos-complement number X into an m-bit one, but some

21、 care is needed. If m n, we must append m - n copies of Xs sign bit to the left of X . That is, we pad a positive number with 0s and anegative one with 1s; this is called sign extension. If m n, we discard Xs n m leftmost bits; however, the result is valid only if all of the discarded bits are the s

22、ame as the sign bit of the result .,Example for Sign extension,Please convert these twos complement numbers 01111 and 1001 into 8-bit.01111=00001111 1001=11111001,NOTE: the result of extension is in the Twos-complement number system.,2.6 Twos Complement Addition and Subtraction (二进制补码的加法和减法),we defi

23、ne x to be the twos complementrepresentation of x x + y = ( x + y ) x - y = ( x + -y ) x为x的二进制补码表示。,2.6 Twos Complement Addition and Subtraction (二进制补码的加法和减法),x + y = ( x + y ) ;x - y = ( x + -y ) 1101+1010=?1101+1101=?,OVERFLOE?,4 bits binary number,0000,0001,0010,0011, 0100, 0101, 0110, 0111, 1000

24、, 1001, 1010,1011, 1100, 1101, 1110, 1111,4位有符号二进制( Signed-Magnitude ),Range: -7+7,4位无符号二进制数,Range: 0+15,4位二进制补码,Range: -8+7,4位有符号二进制数 ( Signed-Magnitude ),Range: -7+7,Two possible representations of Zero!Adds Signed-Magnitude numbers must examine the sign of the adders. Two numbers Can not always b

25、e adders or subtracted directly.,3+4=? 4-3=? 3-4=?x,P35,4位无符号二进制数,Range: 0+15,In summary, in unsigned addition the carry or borrow in the most significant bit position indicates an out-of-range result.,P43,4位二进制补码,Range: -8+7,In signed, twos-complement addition the overflow condition defined earlier

26、 indicates an out-of-range result. overflow may or may not occur independently of whether or not acarry occurs.,-8+2=? -8+5=? 0+3=? 0+6=? 2+7=? x Overflow,We can added +n to that number by counting up n times, that is, by moving the arrow n positions clockwise.We can subtract n from a number by coun

27、ting down n times, that is, by moving the arrow n positions counterclockwise. . The result will always be correct sum as long as the range of the number system is not exceeded.,Modular counting (模计算) -n,What is most interesting is that we can also subtract n (or add -n) by moving the arrow 16 - n po

28、sitions clockwise. Notice that the quantity 16 - n is what we defined to be the 4-bit twos complement of n, that is, the twos-complement representation of n. (P41),2.6.3 Overflow(溢出)(P41)如果加法运算产生的和超出了数制表示的范围,则结果发生了溢出(Overflow)。 对于二进制补码,加数的符号相同,和的符号与加数的符号不同。(C in 与 C out 不同) P.28 对于无符号二进制数,若最高有效位上发生进位或借位,就指示结果超出范围。5 1011 7 0111 6 1010 3 0011 11 10101 5 10 1 010 6,Home work P(75-76),1、2.11 2、2.12 3、2.22,返回,Please hand your home work on next Tuesday.,

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报