(2.3)--2.3Representationofintegers.pdf
《(2.3)--2.3Representationofintegers.pdf》由会员分享,可在线阅读,更多相关《(2.3)--2.3Representationofintegers.pdf(11页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、Representation of integersRepresentation of integers2.3Integer includes positive integers 1,2,3,.,n,.,0(zero),as well as negativeintegers-1,-2,-3,.,-n,.,where n is an integer.In computers,binary numbers are used to represent integers in two forms:unsigned(unsigned integers)and signed(signed integers
2、).Unsigned integers can onlyrepresent positive integers and 0.Signed integers can be used to represent positiveintegers,0,and negative integers.Representation of integers2.3Representation of unsigned integerThe encoding of an unsigned integer is the same as its value.Therefore,anunsigned integer can
3、 only represent positive integers and 0.Solution:01001011(binary)=027+126+025+024+123+022+121+120=0+64+0+0+8+0+2+1=75Therefore,binary number 01001011 represents unsigned integer 75.Eg1Assuming that the binary number 01001011 represents an unsigned integer,then whats the value of the unsigned integer
4、 it represented?Representation of integers2.3Its thinking is to digitize the sign of a number.For n-bit signed integers,use the most significant bit(MSB)to represent its sign:Positive numbers take 0,and negative numbers take 1.The remaining(n-1)digits are numeric digits,where the absolute value of t
5、he number is stored.If the absolute value isfewer than n-1 digits,make up with 0.1.Sign-magnitude representationSolution:xsign-magnitude=01011011ysign-magnitude=11011011zsign-magnitude=10010110Eg2Assume that x=+1011011,y=-1011011,and z=-10110(=-0010110),write out the8-bit binary form of x,y,and z us
6、ing sign-magnitude representation.Representation of signed integerRepresentation of integers2.3The range of an 8-bit sign-magnitude representation is:-127x127-(28-1)x(28-1)Representation of integers2.32.Complement representationsThe method to calculate complement(twos complement):The twos complement
7、 of a positive number is the same as its sign-magnituderepresentation.The twos complement of a negative number equals the bitwise NOT(0-1,1-0)ofits sign-magnitude except for the sign bit(also called ones complement)plus 1.Representation of integers2.3Eg3How to represent 75 with 1 byte in computer?So
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2.3 Representationofintegers
限制150内