NumberSystemsandBooleanAlgebraKeypoints:usefultermsanddefinitionsofNumbersystemandBooleanAlgbraDifficultpoints:ConversionoftheNumberSystemsandBooleanAlgbraRequirements:1.ConceptsofNumberSystemandtheirconversion2.BooleanAlgebra3.Moore’sLaw4.科技英语中数学公式的读法3-4NewWords&Expressions:hexadecimaladj.十六进制的;n.十六进制radixn.根,基数octaladj.八进制的;n.八进制alphabetn.字母表fractionaladj.分数的,小数的wholenumbern.整数remaindern.余数significantfiguren.有效数字quotientn.商algorithmn.算法complementn.补码,余角carryn.进位*NumberSystems3-5Theuseofthemicroprocessorrequiresaworkingknowledgeofbinary,decimal,andhexadecimalnumberingsystems.Thissectionprovidesabackgroundforthosewhoareunfamiliarwithnumbersystems.Conversionsbetweendecimalandbinary,decimalandhexadecimal,andbinaryandhexadecimalaredescribed.*NumberSystems使用微处理器需要掌握二进制、十进制和十六进制数制系统的基本知识,本节为那些不熟悉数制系统的读者提供这方面的背景知识。说明了十进制与二进制之间、十进制与十六进制之间,及二进制与十六进制之间的转换。3-6Ifthebaseofanumberexceeds10,theadditionaldigitsusethelettersofthealphabet,beginningwithanA,Forexample,abase12(定语)numbercontains12digits:0through9,followedbyAfor10andBfor11,Notethatabase10numberdoesnotcontaina10digit,justasabase8numberdoesnetcontainan8digit.Themostcommonnumberingsystemsusedwithcomputersaredecimal,binary,andhexadecimal(base16).(Manyyearsagooctalnumberswerepopular.)*Digits如果基数大于10,其余数字用从A开始的字母表示,例如,以12为基的数包含12个数字,0到9,之后用A代表10,B代表11。注意,以10为基的数不包含数字10,如同以8为基的数不包括数字8一样。计算机中最通用的计数制是十进制、二进制、八进制和十六进制(基为16)。3-7Theexponentialpowersofthepositionsarecriticalforunderstandingnumbersinothernumberingsystems.Thepositiontotheleftoftheradix(numberbase)point,calledadecimalpointonlyinthedecimalsystem,isalwaystheunitspositioninanynumbersystem.Forexample,thepositiontotheleftofthebinarypointisalways20or1;thepositiontotheleftoftheoctalpointis80or1.Inanycase,anynumberraisedtoitszeropowerisalways1,ortheunitsposition.*PositionalNotation位的指数幂在理解其他计数制中的数时是个关键。基数小数点,在十进制中称为十进制小数点,其左边的位在任何数制中都是个位。例如,二进制小数点左边的位是20或1。而八进制小数点左边的位是80或1。在任何情况下,任何数的零次幂总是1,或1个单位。3-8Thepositiontotheleftoftheunitspositionisalwaysthenumberbaseraisedtothefirstpower;inadecimalsystem,thisisl01,orl0.Inabinarysystem,itis21,or2;andinanoctalsystemitis81,or8.Therefore,an11decimalhasadifferentvaluefroman11binary.The1ldecimaliscomposedof1tenplus1unitandhasavalueof11units;whilethebinarynumber11iscomposedof1twoplus1unit,foravalueof3decimalunits.The11octalhasavalueof9units.*PositionalNotation个位左边的位总是基数的1次幂,在十进制系统中是101,或10;在二进制中是21,或2;而在八进制中是81,或8。因此,十进制的11与二进制的11具有不同的数值。十进制11表示—个10加上一个1,其值为11;二进制11表示—个2加上—个1,其值为3;八进制11的值为9。3-9Inthedecimalsystem,positionstotherightofthedecimalpointhavenegativepowers.Thefirstdigittotherightofthedecimalpointhasavalueof10-1,or0.1.Inthebinarysystem,thefirstdigittotherightofthebinarypointhasavalueof2-1,or0.5.Ingeneral,theprinciplesthatapplytodecimalnumbersalsoapplytonumbersinanyothernumbersystem.3.1.2PositionalNotation在十进制系统中,对于十进制小数点右边的位,它的幂为负数。十进制小数点右边第一位数的值为10-1,或0.1。在二进制中,二进制小数点右边第—位数的值为2-1或0.5。一般来说,十进制使用的计数法可以用于任何其他数制。3-10Example3-1showsa110.101inbinary(oftenwrittenas110.1012).Italsoshowsthepowerandweightorvalueofeachdigitposition.Toconvertabinarynumbertodecimal,addtheweightsofeachdigittoformitsdecimalequivalent.The110.1012isequivalenttoa6.625indecimal(4+2+0.5+0.125).Noticethatthisisthesumof22(or4)plus21(or2),but20(or1)isnotaddedbecausetherearenodigitsunderthisposition.Thefractionpartiscomposedof2-1(0.5)plus2-3(or.125),butthereisnodigitunderthe2-2(or.25).例3-1给出了一个二进制数110.101,也给出了这个数每个位的幂、权和值。为了把二进制数转换为十进制,将每位数字的权相加,就得到了它的等效十进制值。二进制110.101等于十进制的6.625(4+2+0.5+0.125)。注意,这个和的整数部分是由22(4)加21(2)构成,之所以没有用20(1)是因为这个位的数为零。小数部分由2-1(0.5),加2-3(0.125)构成,但是没有用2-2(0.25)。3-11Thepriorexampleshaveshownthattoconvertfromanynumberbasetodecimal,determinetheweightsorvaluesofeachpositionofthenumber,andthensumtheweightstoformthedecimalequivalent.Supposethata125.78octalisconvertedtodecimal.Toaccomplishthisconversion,firstwritedowntheweightsofeachpositionofthenumber.ThisappearsinExample3-2.Thevalueof125.78is85.875decimal,or164plus28plus51plus7.125.*ConversiontoDecimal前面的例子说明了将任何其他基数的数转换为十进制数时,十进制数的值取决于该数每个位上的权或值,它们的和就是等效的十进制数值。假定要将125.78(八进制)转换为十进制。为了完成这个转换,首先写出该数每一位数的权,如例3-2所示,125.78的值是十进制的85.875,即164+28+51+70.125。3-12Noticethattheweightofthepositiontotheleftoftheunitspositionis8.Thisis8times1.Thennoticethattheweightofthenextpositionis64,or8times8.Ifanotherpositionexisted,itwouldbe64times8,or512.Tofindtheweightofthenexthigher-orderposition,multiplytheweightofthecurrentpositionbythenumberbase(or8,inthisexample).Tocalculatetheweightsofpositiontotherightoftheradixpoint,dividebythenumberbase.Intheoctalsystem,thepositionimmediatelytothefightoftheoctalpointis1/8,or.125.Thenextpositionis.125/8,or.015625,whichcanalsobewrittenas1/64.注意,该数个位左边那位的权是8(18)。再前一位的权是64(88)。如果存在更前一位,则其权将是512(648)。将当前位的权乘上基数,就可得到更高一位的权(本例中是乘8)。而计算小数点右边那些位的权,需要用基数去除。在八进制中,紧跟八进制小数点右边的那位的权是1/8,即0.125。下一位是0.125/8,即0.015625,也可以写成1/64。3-13Hexadecimalnumbersareoftenusedwithcomputers.A6A.CH(Hforhexadecimal)isillustratedwithitsweightsinExample3-3.Thesumofitsdigitsis106.75,or106.Thewholenumberpartisrepresentedwith616plus10(A)1.Thefractionpar