




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
CS1104 Computer Organization 8Number System and Coding Number system consists of an ordered set of digits, with relations defined for +, -, * and /. The radix (r) or base of a number system indicates the total number of digits allowed in the number system. Common number system include:- decimal- binary- octal - hexadecimalPositional NotationsWeighted-Positional notation Decimal Number System - symbols used: 0,1,2,3, 9 0 1 2 3 4 Position of each digit is important.10e.g. (40982) = 4x10 + 0X10 + 9X10 + 8X10 +2X10 0 n-1 nIn general: (an an-1 an-2 a0)10 = (anx10 ) + (an-1x10 )+(a0x10 )FractionsFractions are written in decimal numbers after the decimal point. -2 2 -1 2 0 2 1 2e.g. 333/4 = (33.75)10. = (3x10 ) + (3x10 ) + (7x10 ) + (5x10 )In case of recurring fraction, use for recurring position.e.g. 21/3 = (2.333333)10 = (2.3)10-m n-1 -1 0 nIn general, (an an-1a0.f1 f2 fm)10 = (anx10 )+(an-1x10 )+(a0x10 )+(f1x10 )+(fmx10 )Conversion Between Bases In general, conversion between bases can be done via:Base-2Base-3Base-rBase-2Base-3Base-rDecimal.Base r Decimal 0 2 n-2 2 n 2Binary(base 2) Decimal -m 2 -2 2 -1 2General: (an an-1 an-2 a0.f1 f2fm)2 = (anx2 ) + (an-1x2 )+(a0x2 ) + (f1x2 )+(f2x2 )+(fmx2 ) -2 2 1 2 2 2 4 2e.g (10110.01)2 = (1x2 )+(1x2 )+(1x2 )+(1x2 ) = (22.25)10Octal(base 8) Decimal -1 2 1 2 0 2e.g. (47.5)8 = (4x8 )+(7x8 )+(5x8 ) = (39.625)10Hexadecimal(base 16) Decimal -1 2 0 2 1 2 2 2 3 2e.g (BAD2.C)16 = (11x16 )+(10x16 )+(13x16 )+(2x16 )+(12x16 ) = (47826.75)10Note: Hexadecimal digits are 0,1,2,3,4,5,6,7,8,9,A.B,C,D,E,F where A=10, B=11,C=12,D=13,E=14,F=15. -m 2 -2 2 -1 2 0 2 n-1 2 n 2Generally, for Base r Decimal, (an an-1 an-2 a0.f1 f2fm)r = (an x r ) + (an-1 x r )+(a0 x r ) + (f1 x r )+(f2 x r )+(fm x r )Decimal Base rGenerally, (an an-1 a0.f1 f2 fp)10 (bm bm-1 b0.g1 g2 gq)rInteger partNote that Integers(whole number) and fractions are converted separately.Fraction parti.e. (an an-1 a0)10 (bm bm-1 b0)r (f1 f2 fp)10 (g1 g2 gq)rDecimal Binary(base 2)e.g. convert (41.375)10 to binary representation1.Integer partmethod: Coefficients obtained from remainders of successive division by 2. The first remainder is the least significant bit(LSB) and the last remainder is the most significant bit(MSB).(41)10 = (101001)241/2 =20 rem 120/2 =10 rem 010/2 =5 rem 05/2 =2 rem 12/2 =1 rem 01/2 =0 rem 1Hence result: (101001)2 2.Fractional partmethod: Coefficients of binary fraction obtained by successive multiplication of decimal fraction by 2. Coefficient will appear as integer portion of successive multiplication.(.375)10 = (.011)2 .375 x 2 = 0.75 0MSB.75 x 2 = 1.5 1.5 x 2 = 1.0 1LSBHence result: (.011)2In general: Decimal Base r- whole number: repeated division by r- fractions : repeated multiplication by rBinary Octal / Hexadecimal ConversionOctal- 1 octal digit = 3 binary digits(bits)e.g. (001)2 = (1)8(101)2 = (5)8 (010)2 = (2)8(111)2 = (7)8Techniques for converting binary octal group 3-bits and convert into corresponding octal digit.e.g. (10 110 001 101 011 111 100 000 1)2 =(2 6 1 5 3 7 4 0 4)8Hexadecimal- 1 hexadecimal digit = 4 bitse.g. (1111)2 = (F)16(1000)2 = (8)16 (1010)2 = (A)16(0010)2 = (2)16Techniques for converting binary hexadecimal group 4-bits and convert into corresponding hexadecimal digit.e.g. (10 1100 0110 1011 . 1111 0000 01)2 =(2 C 6 B F 0 4)16 Negative NumbersSign&MagnitudeNegative numbers are usually written by prepending a MINUS SIGN(-) in front.e.g. (7)10, -(0111)2In computer memory of fixed width, this sign is usually represented by a bit.- 0 for +- 1 for - Given a 8-bit number, MSB is the sign bit and the remaining 7 bits are magnitude.Note: to negate a number, just invert the sign bite.g. (0 0110010) = (1 0110010)sm (1 0111010) = (0 0111010)sm1s Complementn 2Given an n-bit number, x, its negative number can be obtained in 1s complement representation using:x = 2 x 1e.g. given an 8-bit number: 8 2 (01001100)2 = (96)10= (2 96 1) 10=(159)10=(10110011)1sTechnique is INVERT all bits.(10 or 0 1) (01010101)2 = (10101010)1sNote, given a positive n-bit binary number, its 1s complement representation is still the same as the binary number.e.g. +(00011001)2 = (00011001)1s2s Complement n 2Given an n-bit binary number, x, its negative number can be obtained in 2s complement representation using:x = 2 x e.g. given an 8-bit number: 8 2 (01001100)2 = (96)10 = (2 96)10 = (160)10 = (10110100)2sTechnique is INVERT all the bits and ADD 1e.g. (01010101)2 = (10101010)1s (invert) = (10101011)2s (add 1)Note: Given a positive n-bit number, its 2s complement representation is still the same as the binary number.e.g. +(00100100)2 = (00100100)2sComplementIn general, for base-r number, there are:- Diminished Radix (or r-1s) complement- Radix (or rs) complementDiminished Radix Complement n 2Given an n-digit number, (N)r, its (r-1s) complement is:(r 1) N 2 2e.g. The (r-1s) complement, or 9s complement of (15)10 is:(10 1) 15 = 99 5= (84)9s 3 2The (r-1s) complement, or 7s complement of (327)8 is:(8 1) (327)8 = 777 327 = (450)7sRadix Complement n 2Given an n-digit number, (N)r, its rs complement is:r Ne.g. The rs complement, or 10s complement of (15)10 is: 2 210 15 = 100 15 = (85)10sTechnique is use: (r-1s) complement + 1 2 2e.g. The 8s complement of (57)8 is:(8 1) (57)8 = 77 57 (7s complement) = (20)7s + 1 (add 1) = (21)8s (8s complement)Subtraction - Using r-Complement- Using r-1 ComplementSubtraction using r-Complement n 2 n 2Technique: Given 2 unsigned base-r numbers, M & N, Subtraction of (MN) is done by: n 21. add M to the r-complement N: M + (r N) = (MN) + r 2. if M = N, then there will be an end-carry r . So discard this end carry. n 2 n 23. if M N, then there will be an end-carry r . So discard this end carry and add 1 to get: (MN1) + 1 = M N n 2 n 2 n 2 n 2 n 23. if M = N, then there is no end carry, but have ve result(incl 0): (M-N-1)+ r To get the normal form, take (r-1) complement to get: (r 1) (MN) + r ) = N-M. Then put MINUS sign in front(if result is not 0).e.g.(33)10 (22)10 = 33 +(99-22)9s = (33 + 77)9s = (110)9s (discard end carry, add 1) = (10 +1)10 = (11)10(10)10 (22)10 = 10 + (99 22)9s = (10 + 77)9s = (87)9s(no end carry, so complement it) = -(99 87)10 = -(12)10 Fixed Point NumbersSigned and unsigned numbers representation are fixed point numbers. The binary point is assumed to be at a fixed position. Binary pointBut the binary point can also be in other locations.e.g. 123.23, 12.323Cons of fixed point numbers: It have limited range. 23 2To represent very large numbers or very small numbers, need to use floating point numbers. -10 2e.g. 0.23 x 10 (very large positive number) -0.1236 x 10 (very small negative number|)Floating Point Numbers- consist of 3 parts: mantissa, base and exponent.Since base is usually fixed, only need mantissa and exponent. 23 2 21 2Mantissa is usually in normalized form. 19 2 21 2i.e. 23 x 10 is normalized to 0.23 x 10 -0.0017 x 10 is normalized to 0.17 x 10A 32-bit number can have 24-bit mantissa and 8-bit exponent.More bits in exponent gives larger range.More bits in mantissa gives better precision.Floating Point Arithmetic Addition Steps: (i) equalise the exponents (ii) add-up the mantissa (iii) normalisee.g:(0
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025至2030中国伊托必利行业运营动态与需求前景研究报告
- 2025至2030中国二氯苯行业供需现状及应用领域需求研究报告
- 2025-2030餐饮行业市场发展现状及竞争形势与投资前景研究报告
- 2025-2030面糊预混料行业市场现状供需分析及重点企业投资评估规划分析研究报告
- 2025-2030酒柜行业市场发展分析及前景趋势与投资研究报告
- 2025-2030车险行业市场深度调研及前景趋势与投资研究报告
- 2025-2030航空租赁产业市场深度分析及前景趋势与投资研究报告
- 2025-2030脑膜瘤药行业市场现状供需分析及重点企业投资评估规划分析研究报告
- 2025-2030硝基苯甲酸钾盐行业市场现状供需分析及重点企业投资评估规划分析研究报告
- 2025-2030电梯逆变器行业市场现状供需分析及重点企业投资评估规划分析研究报告
- 动脉取栓知识讲座
- 2023年市场部经理岗位职责
- 酒店毕业季促销策划方案
- 孕产期心理危机干预和自救技巧
- 输尿管肿瘤护理课件
- 精气神完整分
- 电气控制及PLC应用技术(基于西门子S7-1200)活页式 课件 项目九 西门子S7-1200高级应用
- 初中函数-图像练习坐标纸(A4)直接打印版本
- 各级无尘室尘埃粒子测量表
- 成人本科学士学位英语词汇
- 第7课《溜索》一等奖创新教学设计
评论
0/150
提交评论