文稿buaasoft2016硬件基礎(chǔ)_第1頁
文稿buaasoft2016硬件基礎(chǔ)_第2頁
文稿buaasoft2016硬件基礎(chǔ)_第3頁
文稿buaasoft2016硬件基礎(chǔ)_第4頁
文稿buaasoft2016硬件基礎(chǔ)_第5頁
已閱讀5頁,還剩29頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

Today:FloatingPointBackground:FractionalbinarynumbersIEEEfloatingpointstandard:DefinitionExampleandpropertiesRounding,addition,multiplicationFloatingpointinCFractionalbinarynumbersWhatis1011.1012?2i2i-14211/21/41/82-jbibi-1???b2b1b0b-1b-2b-3???b-j???FractionalBinaryNumbersRepresentationBitstorightof“binarypoint”representfractionalpowersof2Representsrationalnumber:???FractionalBinaryNumbers:Examples

RepresentableNumbersLimitationCanonlyexactlyrepresentnumbersoftheformx/2kOtherrationalnumbershaverepeatingbitrepresentationsValue Representation1/3 0.[01]…21/5 0.[0011]…21/10 0.0[0011]…2Today:FloatingPointBackground:FractionalbinarynumbersIEEEfloatingpointstandard:DefinitionExampleandpropertiesRounding,addition,multiplicationFloatingpointinCIEEEFloatingPointAfloating-pointrepresentationEncodesrationalnumbersoftheformV=x×2yUsefulfor:verylargenumbers(|V|>>0) 234numbersverycloseto0(|V|<<1) 2-34moregenerallyasanapproximationtorealarithmeticHardtomakefastinhardwareIEEEStandard754Establishedin1985asuniformstandardforfloatingpointarithmeticBeforethat,manyidiosyncraticformatsSupportedbyallmajorCPUsNumericalForm:

(–1)s

M2ESignbit

sdetermineswhethernumberisnegativeorpositiveSignificand

Mnormallyafractionalvalueinrange[1.0,2.0).Exponent

EweightsvaluebypoweroftwoEncodingMSBsissignbitsexpfieldencodesE(butisnotequaltoE)fracfieldencodesM(butisnotequaltoM)FloatingPointRepresentationsexpfracPrecisionsSingleprecision:32bitsDoubleprecision:64bitsExtendedprecision:80bits(Intelonly)sexpfrac18-bits(k=8)23-bits(n=23)sexpfrac111-bits52-bitssexpfrac115-bits63or64-bitsCategoriesofsingle-precision,floating-pointvaluesNormalizedValuesCondition:exp≠000…0andexp≠111…1Value:(–1)s

M2EExponentcodedasbiasedvalue:E=Exp–BiasExp:unsignedvalueexp

Bias

=2k-1-1,wherekisnumberofexponentbitsSingleprecision:127(Exp:1~254,E:-126~127)Doubleprecision:1023(Exp:1~2046,E:-1022~1023)Significandcodedwithimpliedleading1:M=1.xxx…x2

xxx…x:bitsoffracMinimumwhen000…0(M=1.0)Maximumwhen111…1(M=2.0–ε)Getextraleadingbitfor“free”NormalizedEncodingExampleValue:FloatF=15213.0;1521310= 111011011011012(14bits)= 1.11011011011012x213SignificandM = 1.11011011011012frac = 000002ExponentE = 13Bias = 127Exp = E+Bias = 140 = 100011002Result:

sexpfrac01000110000000DenormalizedValuesCondition:exp=000…0Value:(–1)s

M2EExponentvalue:E=1–Bias(insteadofE=0–Bias)Significandcodedwithimpliedleading0:M=0.xxx…x2xxx…x:bitsoffracCases

exp=000…0,frac=000…0RepresentszerovalueNotedistinctvalues:+0and–0exp=000…0,frac≠000…0Numbersverycloseto0.0EquispacedSpecialValuesCondition:exp=111…1Case:exp=111…1,frac=000…0Representsvalue(infinity)OperationthatoverflowsBothpositiveandnegativeE.g.,1.0/0.0=?1.0/?0.0=+,1.0/?0.0=?Case:exp=111…1,frac≠000…0Not-a-Number(NaN)RepresentscasewhennonumericvaluecanbedeterminedE.g.,sqrt(–1),?,

0Visualization:FloatingPointEncodings+?0+Denorm+Normalized?Denorm?Normalized+0NaNNaNToday:FloatingPointBackground:FractionalbinarynumbersIEEEfloatingpointstandard:DefinitionExampleandpropertiesRounding,addition,multiplicationFloatingpointinCDistributionofValues6-bitIEEE-likeformate=3exponentbitsf=2fractionbitsBias=23-1-1=3Noticehowthedistributiongetsdensertowardzero.8valuessexpfrac13-bits2-bitsDistributionofValues(close-upview)6-bitIEEE-likeformate=3exponentbitsf=2fractionbitsBiasis3sexpfrac13-bits2-bitsTinyFloatingPointExample8-bitFloatingPointRepresentationthesignbitisinthemostsignificantbitthenextfourbitsaretheexponent,k=4Bias=2k-1–1=7thelastthreebitsarethefrac,n=3SamegeneralformasIEEEFormatnormalized,denormalized,specialrepresentationof0,infinity,NaNsexpfrac14-bits3-bitssexpfrac E

Value

00000000 -6 000000001 -6 1/8*1/64=1/51200000010 -6 2/8*1/64=2/512…00000110 -6 6/8*1/64=6/51200000111 -6 7/8*1/64=7/51200001000 -6 8/8*1/64=8/51200001001 -6 9/8*1/64=9/512…00110110 -1 14/8*1/2=14/1600110111 -1 15/8*1/2=15/1600111000 0 8/8*1=100111001 0 9/8*1=9/800111010 0 10/8*1=10/8…01110110 7 14/8*128=22401110111 7 15/8*128=24001111000 n/a inf01111xxx n/aNaNDynamicRange(PositiveOnly)closesttozerolargestdenormsmallestnormclosestto1belowclosestto1abovelargestnormDenormalizednumbersNormalizednumbersInterestingNumbersDescription exp frac NumericValueZero 00…00 00…00 0.0SmallestPos.Denorm. 00…00 00…01 2–{23,52}x2–{126,1022}Single≈1.4x10–45Double≈4.9x10–324LargestDenormalized 00…00 11…11 (1.0–ε)x2–{126,1022}Single≈1.18x10–38Double≈2.2x10–308SmallestPos.Normalized 00…01 00…00 1.0x2–{126,1022}JustlargerthanlargestdenormalizedOne 01…11 00…00 1.0x20LargestNormalized 11…10 11…11 (2.0–ε)x2{127,1023}Single≈3.4x1038Double≈1.8x10308{single,double}SpecialPropertiesofEncodingFPZeroSameasIntegerZeroAllbits=0Can(Almost)UseUnsignedIntegerComparisonMustfirstcomparesignbitsMustconsider?0=0NaNsproblematicWillbegreaterthananyothervaluesOtherwiseOKDenormvs.normalizedNormalizedvs.infinityToday:FloatingPointBackground:FractionalbinarynumbersIEEEfloatingpointstandard:DefinitionExampleandpropertiesRounding,addition,multiplicationFloatingpointinCFloatingPointOperations:BasicIdeax+fy=Round(x+y)xfy=Round(xy)BasicideaFirstcomputeexactresultMakeitfitintodesiredprecisionPossiblyoverflowifexponenttoolargePossiblyroundtofitintofracRoundingRoundingModes(illustratewith$rounding) 1.40 1.60 1.50 2.50 –1.50Towardszero 1 1 1 2 –1Rounddown(?) 1 1 1 2 –2Roundup(+) 2 2 2 3 –1NearestEven(default) 1 2 2 2 –2Whataretheadvantagesofthemodes?CloserLookatRound-To-EvenDefaultRoundingModeAllothersarestatisticallybiasedSumofsetofpositivenumberswillconsistentlybeover-orunder-estimatedApplyingtoOtherDecimalPlaces/BitPositionsWhenexactlyhalfwaybetweentwopossiblevaluesRoundsothatleastsignificantdigitisevenE.g.,roundtonearesthundredth 1.2349999 1.23 (Lessthanhalfway) 1.2350001 1.24 (Greaterthanhalfway) 1.2350000 1.24 (Halfway—roundup) 1.2450000 1.24 (Halfway—rounddown)RoundingBinaryNumbers

FPMultiplication(–1)s1

M12E1x(–1)s2

M22E2ExactResult:(–1)s

M2ESigns: s1^

s2SignificandM: M1x

M2ExponentE: E1+

E2FixingIfM≥2,shiftMright,incrementEIfEoutofrange,overflowRoundMtofitfracprecisionImplementationBiggestchoreismultiplyingsignificandsFloatingPointAddition(–1)s1

M12E1+(-1)s2

M22E2AssumeE1>E2ExactResult:(–1)s

M2ESigns,significandM:Resultofsignedalign&addExponentE: E1FixingIfM≥2,shiftMright,incrementE

ifM<1,shiftMleftkpositions,decrementEbykOverflowifEoutofrangeRoundMtofitfracprecision(–1)s1

M1

(–1)s2

M2

E1–E2+(–1)s

MMathematicalPropertiesofFPAddComparetothoseofAbelianGroupClosedunderaddition? ButmaygenerateinfinityorNaNCommutative?Associative?Overflowandinexactnessofrounding(3.14+1e10)-1e10vs3.14+(1e10-1e10)0isadditiveidentity?EveryelementhasadditiveinverseExceptforinfinities&NaNsMonotonicitya≥b?a+c≥b+c?Exceptforinfinities&NaNsYesYesYesNoAlmostAlmostMathematicalPropertiesofFPMultComparetoCommutativeRingClosedundermultiplication?ButmaygenerateinfinityorNaNMultiplicationCommutative?MultiplicationisAssociative?Possibilityofoverflow,inexactnessofrounding1ismultiplicativeidentity?Multiplicationdistributesoveraddition?Possibilityofoverflow,inexactnessofroundingMonotonicitya≥b&c≥0?a*c≥b*c?Exceptforinfinities&NaNsYesYesNoYesNoAlmostToday:FloatingPointBackground:FractionalbinarynumbersIEEE

溫馨提示

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

最新文檔

評論

0/150

提交評論