版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1Digital Logic Design and ApplicationJin YanhuaLecture #2General Positional-Number-System ConversionAddition and Subtraction of Nondecimal NumbersRepresentation of Negative NumbersUESTC, Spring 2014Jin. UESTC2Chapter 2Number Systems and CodesHow can numeric quantities be represented and manipulated?
2、How can nonnumeric data, events, and conditions be represented?Jin. UESTC32.1 Positional Number SystemsThe traditional number system is called a positional number system. For example: 3567 = 3*1000 + 5*100 + 6*10 + 7*1A number is represented as a string of digits.Each digit position has a associated
3、 weight.Numbers value = a weighted sum of the digitsDecimal fractions: weights are negative powers of 10Jin. UESTC42.1 Positional Number SystemsIn general, a number D can be represented asD = dp-1 dp-2 . d1 d0 . d-1 d-2 . d-nD2 = d i 2i D16= d i 16i r: Base or Radix of r number system(计数的基数)ri: Weig
4、ht corresponding to the digits position(第i位的权)Jin. UESTC52.2 Octal and Hexadecimal NumbersBinary-to-Octal or Hexadecimal conversion Octal- or Hexadecimal- to-Binary conversion1000110010012 = ( )8 = ()16RadixDigitsBinary20,1Octal807Hexadecimal1609,AF(11011.10101)2= ( 23.52 )8= ( 1B.A8 )16How to conve
5、rt to decimalJin. UESTC62.3 General Positional-Number-System ConversionRadix-r-to-DecimalExample 1:( 101.01 )2 = ( )10 ( 7F.8 )16 = ( )105.25127.5A shortcut? ( F1AC )16 = ( ( ( F16 ) +1 ) 16 + A ) 16 + CMethod: use the formula nested expansion formula 嵌套形式Jin. UESTC7Decimal-to-Radix-r Conversions Co
6、nvert the integer and fractional parts separately and add the results afterwards.Integer part: Successively divide number by r, taking remainder as result.Example: Convert 5710 to binary57 / 2 = 28 remainder 1 (LSB) /2 = 14 remainder 0 /2 = 7 remainder 0 /2 = 3 remainder 1 /2 = 1 remainder 1 /2 = 0
7、remainder 1 (MSB)Ans: 1110012Jin. UESTC8Decimal-to-Radix-r ConversionsFractional PartExample: convert .310 to binary.3 * 2 = .6 integer part = 0.6 * 2 = 1.2 integer part = 1.2 * 2 = .4 integer part = 0.4 * 2 = .8 integer part = 0.8 * 2 = 1.6 integer part = 1.6 * 2 = 1.2 integer part = 1, etc.Ans: .0
8、100112Successively multiply number by r, taking integer part as result and chopping off integer part before next iteration.May be unending!Jin. UESTC9Decimal-to-Radix-rMethod: Radix Multiplication or Division 1001 11000.01011 2-52.3 General Positional-Number-System ConversionInteger Parts 整数部分:除r取余,
9、逆序排列 Example 2:( 156 )10 = ( )2Decimal Fraction 小数部分:乘r取整,顺序排列 Example 3:( 0.37 )10 = ( )2Jin. UESTC102.3 General Positional-Number-System ConversionExample 4:Require 10-2 ,complete the following conversion ( 617.28 )10 = ( )210 0110 1001 . 0100 0112-n = 10-2 n = 7思考:任意两种进位计数制之间的转换 以十进制(二进制)作为桥梁Jin.
10、 UESTC112.4 Addition and Subtraction of Nondecimal NumbersBinary Addition: Cin(carry in)Cout(carry out)S(sum):Binary Subtraction: Bin(Borrow in)Bout(Borrow out)D(difference) 1011 1110+ 1000 1101 1010 1010 0101 0101Jin. UESTC12Binary addition tableInputOutputXYCinCoutS00000001010100101110100011011011
11、01011111inputoutputXYBinBoutD0000000111010110111010001101001100011111Binary subtraction tableJin. UESTC132.5 Representation of Negative NumbersSigned-Magnitude RepresentationMSB as the sign bit ( 0 = plus, 1 = minus ) 000010012 = = 910 011111112 = = 12710 000000002 = = 010There are two possible repr
12、esentations of Zero.An equal number of positive and negative integers.An n-bit signed-magnitude integer range is ( 2n-11) + ( 2n-11) Adders for singed-magnitude systems are more complex.Jin. UESTC142.5 Representation of Negative NumbersComplement Number Systems plement Representation The complement
13、of an n-digit number is obtained by subtracting it from rn。 If a number D is complemented twice, the result is D.Taking the complement is more difficult than changing the sign, but two numbers can be added directly. How to make it easy?Jin. UESTC152.5 Representation of Negative NumbersComplement Num
14、ber Systems plement Representation The complement of an n-digit number is obtained by subtracting it from rn。Diminished plement The Diminished plement of an n-digit number is obtained by subtracting it from rn -1.Jin. UESTC16Two plement Representation2n number(2n 1) number Onescomplement Onescomplem
15、ent + 1 Only one representations of Zero An n-bit two plement range is 2n-1 +(2n-11)Expanding the sign bit 2.5 Representation of Negative NumbersJin. UESTC17Example 5. Write the 8-bit two plement representations for 119.+119 的补码和反码是?解:写出相应正数的二进制表示:11901110111 则其补码可以通过下式算法得到: 全1码:1 1 1 1 1 1 1 1 减去+1
16、19:0 1 1 1 0 1 1 1119的反码:1 0 0 0 1 0 0 0 加1: 1 119的补码:1 0 0 0 1 0 0 1Jin. UESTC18NOTEPositive number has the same: Sign-Magnitude, Ones- Complement, and Twos- Complement 正数的原码、反码、补码相同Jin. UESTC19QuizConvert from decimal to binary: 73.42Write the 8-bit Signed-magnitude, Two plement, and Ones- complement representations for each decimal number: Jin. UESTC20Only one representations of Zero ( 零只有一种表示 ) 00 0 0 0 0
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电子病历行业研究报告
- 电子电力系统课程设计
- 电子汽车营销策略研究报告
- 育苗代加工合同
- 电子时钟的课程设计
- 电子支付课程设计
- 电子技术有什么课程设计
- 航空公司劳动合同(2篇)
- 电子封装综合课程设计
- 电子商城系统课程设计
- 辽宁省沈阳市沈阳市郊联体2024-2025学年高二上学期11月期中英语试题 含解析
- 《员工培训方案》课件
- 2024年贵州省贵阳修文县事业单位招聘133人历年管理单位遴选500模拟题附带答案详解
- 读书分享《非暴力沟通》课件(图文)
- 2024-2030年中国家禽饲养行业发展前景预测和投融资分析报告
- 2024-2030年中国净菜加工行业市场营销模式及投资规模分析报告
- 2024-2025学年广东省佛山市九年级(上)期中数学试卷(含答案)
- 湖南省长沙市雅礼教育集团2024-2025学年高一上学期期中考试数学试题 含解析
- 第二章 空气、物质的构成(选拔卷)(原卷版)
- 云南省昆明市昆十中教育集团2024-2025学年七年级上学期期中测试地理试卷(无答案)
- 2024-2025学年度广东省春季高考英语模拟试卷(解析版) - 副本
评论
0/150
提交评论