數(shù)字電路設計:2-2補碼_第1頁
數(shù)字電路設計:2-2補碼_第2頁
數(shù)字電路設計:2-2補碼_第3頁
數(shù)字電路設計:2-2補碼_第4頁
數(shù)字電路設計:2-2補碼_第5頁
已閱讀5頁,還剩39頁未讀, 繼續(xù)免費閱讀

付費下載

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

class-exercises1、1011100010112=

8=

162、(156)10=()23、convert0.3910toanumberinradix2.Theprecisionmustachieve10%。

tenminutesclass-exercises1、1011100010112=

5613

8=B8B

162、(156)10=(10011100)23、將0.3910轉換為二進制數(shù),要求精度達到10%。

0.01102ReviewofthelastlessonPositionalNumberSystemsMSD,LSD,MSB,LSBGeneralPositional-Number-SystemConversionsAdecimalfraction

AnumberinBinaryradixBinaryadditionandsubtractionBinarynumberswithcertainwidth;Thenumbersalwaysbesetas0.xxxxxxxx;Wecantakethesenumbersasintegersforoperations!MSB/LSB

UnsignednumberOperationsforunsignednumbers0+0=01+0=11+1=10AdditionC:carryS:sum

OperationsforunsignednumbersAddition:Overflow?Wrong!Right!0×A=01×A=AMultiplicationShift-add:useaddersandshift-registers;Theproductwidthwillbe2n!OperationsforunsignednumbersNewruledifferfromaddMaybegetnegativenumbersubtraction

ShouldusesignednumbertoexpresspositiveandnegativeOperationsforunsignednumbersOncethesignednumbersbeused,subtractioncanbemadebyadd!OperationsforunsignednumbersSubtractionruleisnotnecessary!2.5RepresentationofNegativeNumbers

(負數(shù)的表示)2.5.1Signed-MagnitudeRepresentationP34[符號–數(shù)值表示法(原碼)]2.5.2ComplementNumberSystemsP35(補碼數(shù)制)2.5.3Radix-ComplementRepresentation

P36(基數(shù)補碼表示法)2.5.4Two’s-ComplementRepresentation

P37(二進制補碼表示法)2.6Two’s-ComplementAdditionandSubtractionP39

(二進制補碼的加減法)Table2-6

P40(十進制數(shù)與4位二進制數(shù)對照表)2.6.3Overflow

(溢出)

P412.5.1

Signed-MagnitudeRepresentationanumberconsistsofamagnitudeandasymbolindicatingwhetherthemagnitudeispositiveornegative.

MSBastheSignbit(0=plus,1=minus)[最高有效位表示符號位(0=正,1=負)]01111111=+12711111111=-12700101110=+4610101110=-4600000000=+010000000=-02.5.1Signed-MagnitudeRepresentation[符號–數(shù)值表示法(原碼)]TwopossiblerepresentationsofZero[零有兩種表示(+0、–0)]2.Ann-bitsigned-magnitudeintegerrangeis(n位二進制整數(shù)表示范圍):

–(2n-1–1)~+(2n-1–1)Thesigned-magnitudesystemhasanequalnumberofpositiveandnegativeintegers.

P35representtheresultwith8-bitsigned-magnitudeinteger!110-110=?thesigned-magnitudesystemnegatesanumberbychangingitssign.

ComplementNumberSystemsitnegatesanumberbytakingitscomplementasdefinedbythesystem.

2.5.22.5.2ComplementNumberSystems(補碼數(shù)制)radix–Complement(基數(shù)補碼)2.DiminishedRadix–Complement[基數(shù)減1補碼(反碼)]2.5.2ComplementNumberSystems(補碼數(shù)制)ann-bitnumberDD=dn–1dn–2···d1d0

.Theradixpointisontherightandsothenumberisaninteger.Ifanoperationproducesaresultthatrequiresmorethanndigits,wethrowawaytheextrahighorder

digit(s).IfanumberD

iscomplementedtwice,theresultis

D.(P35)

2.5.3Radix-ComplementRepresentationThecomplementofann-digitnumberisobtainedbysubtractingitfromrn.

r’scomplement=rn-D(n位數(shù)D的基數(shù)補碼等于從rn

中減去該數(shù))Example:Table2-4P362.5.3Radix-ComplementRepresentation2.5.3Radix-ComplementRepresentation

r’scomplement=rn-D

IfDisbetween1andrn

–1,thissubtractionproduces

anothernumberbetween1andrn-1.

whatistheresultofthesubtraction,IfDis0?2.5.3Radix-ComplementRepresentation

r’scomplement=rn-D

IfDisbetween1andrn

–1,thissubtractionproduces

anothernumberbetween1andrn-1.

whatistheresultofthesubtraction,IfDis0?0000000…0(n-bit)

(positive)thereisonlyonerepresentationofzeroinaradix-complementsystem.

DiminishedRadix–ComplementRepresentation

[基數(shù)減1補碼表示法(反碼)]

TheDiminishedRadix–Complementofann-digitnumberisobtainedbysubtractingitfromrn-1

[n位數(shù)的反碼等于從rn–1中減去該數(shù)]

Example:Table2-4,2-5P.36(r-1)’sComplement=rn–1-D

*2.5.6(P38)

therearetwo

representationsofzero,positivezero(00×××00)andnegativezero(11×××11).

2.5.3Radix-ComplementRepresentation2.5.3Radix-ComplementRepresentationAdvantagern–D=[(rn-1)-D]+1ThiscanbeaccomplishedbycomplementingtheindividualdigitsofD,2.5.4Two’s–ComplementRepresentation

(二進制補碼表示法)P37Two’s-Complement(二進制補碼的求取):MSB

(thesignbit):1=minus;0=plus

WeightoftheMSB:-2n-13.Therangeofrepresentablenumbersis

-(2n-1)through+(2n-1-1).

Two’s-Complement

(二進制補碼的求取)Example1.Writethe8-bittwo’s-complementrepresentationforthedecimalnumber:-119.(若約定字長是一個字節(jié),試求-11910的補碼表示。)+11910=011101112,asformula(公式):2n-D=(2n-1-D)+128-1:11111111subtract(減去)+119;-0111011110001000

plus(加)1:+1

-11910:100010012Two’s-Complement

(二進制補碼的求取)Example1.Writethe8-bittwo’s-complementrepresentationforthedecimalnumber:-119.(若約定字長是一個字節(jié),試求-11910的補碼表示。)+11910=011101112,

Two’s-Complement

(二進制補碼的求取)Example1.Writethe8-bittwo’s-complementrepresentationforthedecimalnumber:-119.(若約定字長是一個字節(jié),試求-11910的補碼表示。)+11910=011101112,

100010002+1100010012=-11910帶符號位一起按位取反再+1,得到相反數(shù)的補碼.Table2-6Decimaland4-bitnumbers(P40)DecimalSigned-MagnitudeOne’scomplementTwo’scomplement-8————1000-7111110001001-6111010011010-5110110101011-4110010111100-3101111001101-2101011011110-110011110111101000或00001111或000000001000100010001200100010001030011001100114010001000100501010101010160110011001107011101110111SumupfortheComplement

(總結)Positivenumberhasthesame:

Sign-Magnitude,Ones’–Complement,andTwo’s-Complement(正數(shù)的原碼、反碼、補碼相同)

SumupfortheComplement

(總結)

ComplementNumberSystemssigned-magnitudesystem010001101111(010001)(110001)+1710-1710SumupfortheComplement

(總結)

ComplementNumberSystemssigned-magnitudesystem(010001)(101111)(010001)(110001)+1710-1710不變+1710-1710符號位改變符號位不變其余按位取反加1.連同符號位一起按位取反加1.連同符號位一起按位取反加1.符號位改變Signextensionforatwo’scomplementnumber

(符號位擴展)Wecanconvertann-bittwo’s-complementnumberXintoanm-bitone,butsomecareisneeded.Ifm>n,wemustappendm-ncopiesofX’ssignbittotheleftofX.Thatis,wepadapositivenumberwith0sandanegativeonewith1s;thisiscalledsignextension.Ifm<n,wediscard

X’sn–mleftmostbits;however,theresultisvalidonlyifallofthediscardedbitsarethesameasthesignbitoftheresult.ExampleforSignextensionPleaseconvertthesetwo’scomplementnumbers01111and1001into8-bit.01111=000011111001=11111001NOTE:theresultofextensionisintheTwo’s-complementnumbersystem.2.6Two’s–ComplementAdditionandSubtraction

(二進制補碼的加法和減法)wedefine[x]tobethetwo’scomplementrepresentationofx

[x+y]=([x]+[y])[x-y]=([x]+[-y])

2.6Two’s–ComplementAdditionandSubtraction

(二進制補碼的加法和減法)

[x+y]=([x]+[y]);[x-y]=([x]+[-y])1101+1010=?1101+1101=?

OVERFLOE?000000010010001101000101100010011010110111111110101111000111011001234589101315141112764位無符號二進制數(shù)0000000100100011010001011000100110101101111111101011110001110110+0+1+2+3+4+587631254+7+64位二進制補碼Range:-8~+7

Wecanadded+ntothatnumberbycountingupntimes,thatis,bymovingthearrownpositionsclockwise.

Wecansubtractnfromanumberbycountingdownntimes,thatis,bymovingthearrownpositionscounterclockwise..Theresultwillalwaysbecorrectsumaslongastherangeofthenumbersystemisnotexceeded.Modularcounting(模計算)-nWhatismostinterestingisthatwecan

溫馨提示

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

評論

0/150

提交評論