數(shù)字設(shè)計(jì) 第二章_第1頁(yè)
數(shù)字設(shè)計(jì) 第二章_第2頁(yè)
數(shù)字設(shè)計(jì) 第二章_第3頁(yè)
數(shù)字設(shè)計(jì) 第二章_第4頁(yè)
數(shù)字設(shè)計(jì) 第二章_第5頁(yè)
已閱讀5頁(yè),還剩42頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

Chapter2NumberSystemsandCode重點(diǎn):1)二進(jìn)制、八進(jìn)制和十六進(jìn)制數(shù)的表達(dá)及各種數(shù)制之間的相互轉(zhuǎn)換;2)符號(hào)數(shù)的表達(dá)及其加、減運(yùn)算;3)BCD編碼和GRAY碼。4/21/20231.2.1PositionalNumberSystems1.Decimalnumber

Adecimalnumber1536.79d

digits:0、1、2、3、4、5、6、7、8、9weight:10iradix:10power:i,startfromtheleftofthedecimalpoint,increasebyoneforeachsuccessivepositionfrom0;fromtherightofthedecimalpoint,decreasebyonefrom(-1).powerweightdigitradix2.

AnarbitrarydecimalnumberDwithpdigitsinintegerandndigitsinfractiondp-1dp-2……d1d0.d-1d-2……d-nGeneralexpression:2.Binarynumbersradix:2digits:0、1,alsobecalledbit,weight:2i3.Abinarynumber1011010.1012,:※anarbitrarybinarynumberBbp-1bp-2…b1b0

.b-1…b-n,thegeneralexpressions:Thesumofeachdigitmultipliedbythecorrespondingpoweroftheradixisthebinarynumber’sdecimalvalue.4.3.OthersLSB:LeastSignificantBitMSB:MostSignificantBit

bp-1bp-2…b1b0.b-1…b-nMSBLSB5.2.2OctalandHexadecimalNumbers1.conceptOctalHexadecimalradix816weight8i16idigits0、1、2、3、4、5、6、70、1、2、3、4、5、6、7、8、9、A、B、C、D、E、FGeneralexpression6.Exp3:givethedecimalvalueofthefollowingnumbers.215.78=3AD.8h=2.2-8and2-16number’sConvensionsoctal01234567binarysection000001010011100101110111Table1relationbetweenbinaryandoctal7.hexadecimalbinarysection0000010001200103001140100501016011070111hexadecimalbinarysection8100091001A1010B1011C1100D1101E1110F1111Table2binary-hexadecimalrelations8.(a)binary——octal、hexadecimalconversionsStartingatthebinarypoint,separatethebitsintogroupsof3or4,andreplaceeachgroupwiththecorrespondingoctalorhexadecimaldigit.Iftheleftmostgroupfallshortof3or4bits,then0shouldbeaddedtotheleftoftheMSB;sodotheright。Exp:dothefollowingpositional-number-systemconversion。

1111011010.00112=(?)8=(?)hSolution:=1732.148=3DA.3h9.(b)octal,hexadecimal-binarynumberconversionReplaceeachoctalorhexadecimalwiththecorrespondinggroupof3or4bits.Exp:267.248=(?)296CA.28h=(?)210.2.3generalpositional-number-systemconversionsRadix-r-to-decimalconversion:Eachradix-rnumber’sdigitmultiplybyitsownweight,andaddthem.Exp:512.46=(?)d1、decimal-to-radix-rconversion—integerpartmethods:除基取余Theintegerofapdigitsnumberinradixris:Dividetheformulabyrsuccessively,yieldthesuccessivedigitsoftheintegerofD(radixr)fromtherighttolefttillthequotientis0.11.Exp:371d=(?)2=(?)8=(?)h2、decimal-to-radix-rconversion—fractionpartmethods:乘基取整Thefractionofapdigitsnumberinradixris:Multiplytheformulabyrsuccessively,yieldthesuccessivedigitsofthefractionofD(radixr)fromthelefttorighttilltherequireddigitsd-1

,d-2,……,d-n

areacquired.12.Exp8:0.71875d=(?)2=(?)8=(?)h3、summaryofthepositional-number-systemconversions(1)conversionbetweendecimalandradixr(2)radix-r-to-radix-jconversion(non-decimal)binary-to-octal,binary-to-hexadecimalorreverse,beconverteddirectlyconformingtothesection-replacerules.others,radix-rnumber——decimal——radix-jnumber13.2.4additionandsubtractionofnondecimalnumber1、Rulesofbinaryadditionandsubtraction(1)rulesofadditionS=x+y+CinExp:01001011+10001111=?CinxyCoutS0000000101010010111010001101101101011111initialcarrycarry000011110c14.(2)RulesofBinarySubtractiond=x-y-binExp:11001100-01011100=?binxyboutd0000000111010010110010011101101100011111initialborrowborrow011100000b15.2.additionandsubtractionofoctalandhexadecimaladdition:Iftwodigit’ssumisgreaterthantheradixoneachcolumn,thencarry1tothenextmoresignificantbit.subtraction:Iftheminuendislessthansubtrahend,thenborrow1fromthenextmoresignificantbit.16.2.5RepresentationofNegativeNumbers1、signed-magnituderepresentation

unsignednumbers:justthemagnitudeofanumberisrepresented,no‘+’or‘-’signsymbolbeforethenumber。

signednumbers:’+’or‘-’isaddedtotheleftofthenumber。representationofsignednumber:①signsymbol+numbermagnitude,like+34d、-1102、+1Dh、…

17.②inbinarynumber,signbit+magnitudeTheMSBofabitstringisusedasthesignbit:0—“+”,1—“-”thistypeofsignedbinarynumberiscalledSignedMagnitude(S-M碼,或原碼)。比如,+11101=011101-1011=1101118.③TherangeofS-M’srepresentablenumbers.ann-bitS-MnumberB:

bn-1bn-2…b1b0Itsrangeis:-(2n-1-1)~+(2n-1-1)

Includetwozero:-0and+0Exp:findtheS-Mofthefollowingsignednumbers。Howtorepresentbyusing8-bitS-M.+11101,-1011,+18,-18④thefaultofS-Mwhichisusedinarithmeticaloperation:itcan’tbecalculateddirectly.符號(hào)位數(shù)值19.2、ComplementNumberSystemradixcomplement(基數(shù)補(bǔ)碼數(shù)制)diminishedradix-complement(基數(shù)減1補(bǔ)碼數(shù)制)Ann-digitnumberDinradixr:D=dn-1……d1d0,①radix-complement②diminishedradix-complement(也稱基數(shù)反碼)Relationbetweenthesetwo:Table2-4,2-5(P.36)showssomer’sand(r-1)s’complement.20.3.Two’s-complementRepresentation

Two'scomplementisamethodforrepresentingsignedintegersasbinarynumbers.n-bitbinarynumberB=bn-1……b1b0,thetwo’scomplementis:B

2’s=2n-B

forExp.,8-bitbinarynumber two’scomplement 00000000 28-0=00000000 00000001 28-1=11111111 00000010 28-10=11111110 …… …… 11111111 0000000121.Definethesetwo’scomplementassignednumber,theMSBisservedassignbit。

MSB=0,positivenumberMSB=1,negativenumberweightofthesignbit:MSB=0,weight+2n-1

MSB=1,weignt-2n-1Rangeofthevalue:positive—0~+(2n-1-1);

negative—(-2n-1)~-1。Onlyonezerointwo’scomplement.22.two’scomplementnumberandtheirdecimalequivalent2’scomplementdecimal00000000000000001+1…………01111111+12710000000-12810000001-127…………11111110-211111111-123.2’s-complementdecimalequivalentS-M000000000000000001000000000000001+100000001……………..01111111+1270111111110000000-128-10000001-12711111111………………11111110-21000001011111111-11000000124.propertysignbit=0,S-Mandtwo’s-complementhavethesamedecimalvalue;signbit=1,S-Mandtwo’s-complementhavedifferentdecimalvalue。Howtofindthetwo’s-complementrepresentationofanegativedecimalnumber?25.Decimalequivalent4-bits2’scomplement-81000-71001-61010-51011-41100-31101-21110-11111ItsoriginalbinarynumberDecimalequivalent1000801117011060101501004001130010200011互為補(bǔ)數(shù)Samevalue,buthasoppositesignsymbol26.So,tocalculatethe2'scomplementofannegativeinteger,invertthen-bitbinaryequivalentofthegivennumbermagnitudebitbybit,andthenadd1totheLSB.Exp:calculatethe2’scomplementof(+65)and(-65d)in8-bitform.Solution:+6501000001-65binaryequivalentof65is01000001,invertbitbybit10111110add11011111127.Ann-bitbinarynumberB=bn-1……b1b0,theones’-complementis:B

1s’=2n-1-BItisalsothemethodofrepresentingsignedbinarynumbers.MSB=0,positive,weight+(2n-1-1)MSB=1,negative,weight-(2n-1-1)。Rangeofrepresentablenumbers:negative—-(2n-1-1)~-0positive—+0~(2n-1-1)4.Ones’-complementRepresentation28.1s’-complement’spropertyN-bitpositiveintegersarerepresentedinthesamewayasn-bitsign-magnitudenotation.Theones’-complementofann-bitnegativeintegernumberisobtainedbycomplementingeachoneofthebits(then-bitbinarynumber),i.e.,a1isreplacedbya0,anda0isreplacedbya1.Exp.8-bit1s’-complementofthenumber.+18d=00010010-18d=1'scomplementof18=1110110129.decimalS-M2’scomp.1s’comp.-1100111111110-2101011101101-3101111011100-4110011001011-5110110111010-6111010101001-7111110011000-8-1000-decimalS-M2’scomp.1s’comp.7011101110111601100110011050101010101014010001000100300110011001120010001000101000100010001000001000000011110000返回Fromtheleastnumbertobiggestnumber,2’scomp.and1s’comp.aresuccessiveincreasedby1.SummaryofS-M,2’scomp.,1s’comp.30.Allofthesethreeareusedtorepresentsignedintegernumberinbinarysystem.Comparingoftherepresentingrangeofthevalue

Representationsofpositiveintegeraresame;buttherepresentationsofnegativeintegeraredifferentatall.S-M2’scomp.1s’comp.positive+0~(2n-1-1)+0~(2n-1-1)+0~(2n-1-1)negative-(2n-1-1)~-0(-2n-1)~-1-(2n-1-1)~-031.Calculatesignedinteger’sS-M,2’s-comp.,1s’-comp.①positivesignednumber:convertthegivennumberintothewantedn-bitbinaryequivalent.②negativesignednumber:firstconvertthenumberinton-bitbinaryequivalent,

S-M—letMSB=1;

1s’-complement—invertthen-bitbinaryequivalentbitbybit,getthen-bit1s’-comp.;

2’s-complement—add1totheLSBofthen-bit1s’-complementofthegivennumberExp13:FindingtheS-M,2’s-comp,1s’-compofthefollowingsignednumberin8-bit。+60,-60,+10010,-110132.5.SignextensionWhenweconvertann-bit2’scomplementnumberXintoanm-bitone:(a)ifm>n,append(m-n)copiesofX’ssignbittotheleftofX;(b)ifm<n,discardX’s(n-m)leftmostbit。Sodoto1s’-complement.33.2.6Two’s-complementAdditionandSubtraction1、RulesTwooperandsaddorsubtractdirectly

Exp:

3+3,4+(-5),7-3,1-6,符號(hào)數(shù)表格34.2.AgraphicalviewModular:thebiggestnumberofquantitiesthatan-bitsystemcanrepresentis2n.Modularoperation:mMOD2n=m-i·2n(i=int())

Exp:18MOD16=276543210-1-2-3-4-5-6-7-80111011001010100001100100001000011111110110111001011101010011000+235.3.overflowIfanadditionoperationproducesaresultthatexceedstherangeofthenumbersystem,overflowissaidtooccur.thatis,ifresult>+(2n-1-1),or<-(2n-1),overflowisoccurred.Detectingofoverflow:

Anadditionoverflowsiftheaddends’signsarethesamebutthesum’ssignisdifferentfromtheaddends’.Exp:judgewhethertheresultoftheadditionoverflowornot。11111101+1000000136.4.Subtractionrulesm-n=m+(2n-n)Negatethesubtrahendbytakingits2’scomplement,andthenaddittotheminuendusingthenormalrulesforaddition.

2’s-comp.ofn76543210-1-2-3-4-5-6-7-80111011001010100001100100001000011111110110111001011101010011000-2+1437.Exp:8-bit2’s-comp.38.5.Two’s-complementandUnsignedBinaryNumbersWhenn-bitbinarynumbersaretakenforunsignednumber,therulesofadditionandsubtractionareassameasthe2’s-complement.Iftheresultofadditionoperationexceedtherangeofn-bitsystem,acarryisproducedtotheleftmoresignificantbit.39.2.10BinaryCodesforDecimalNumbersEmphasis:BCD,excess-3code:asetofn-bitinwhichdifferentbitstringsrepresentdifferentnumbersofotherthingsiscalledacode.codeword:aparticularcombinationofnbit-values.1、BCDcodethedigits0~9areencodedby4-bitunsignedbinaryrepresentations,0000through1001.andthewords1010~1111arenotused.(invalidcodeword)40.BCD’spropertyBCDisweightedcode,theweightsforthebitsfromlefttorightis:23、22、21、20。alsocalled8421BCD。(1)representingnumbersbyBCDlike,11d,BCD—00010001 256d, BCD–001001010110(2)PackedBCDtwo-digits-per-bytedecimaldigits8421BCD00000100012001030011401005010160110701118100091001Donotdiscardthese041.(3)AdditionwithBCDbesimilarto4-bitunsignedbinarynumberaddition.Butacorrectionmustbemadeifthesumexceeds1001if,sum>1001,thenadd0110totheresult。Exp.:>1001makeacorrection42.2.OtherdecimalcodesP.49table2-9,Excess-3code:th

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論