ieee754

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

WorkinProgress:LectureNotesontheStatusofIEEE754May31,19962:44pmPage1LectureNotesontheStatusofIEEEStandard754forBinaryFloating-PointArithmeticProf.W.KahanElect.Eng.&ComputerScienceUniversityofCaliforniaBerkeleyCA94720-1776Introduction:Twentyyearsagoanarchythreatenedfloating-pointarithmetic.Overadozencommerciallysignificantarithmeticsboasteddiversewordsizes,precisions,roundingproceduresandover/underflowbehaviors,andmorewereintheworks.“Portable”softwareintendedtoreconcilethatnumericaldiversityhadbecomeunbearablycostlytodevelop.Elevenyearsago,whenIEEE754becameofficial,majormicroprocessormanufacturershadalreadyadopteditdespitethechallengeitposedtoimplementors.Withunprecedentedaltruism,hardwaredesignersrosetoitschallengeinthebeliefthattheywouldeaseandencourageavastburgeoningofnumericalsoftware.Theydidsucceedtoaconsiderableextent.Anyway,roundinganomaliesthatpreoccupiedallofusinthe1970safflictonlyCRAYsnow.NowatrophythreatensfeaturesofIEEE754caughtinaviciouscircle:Thosefeatureslacksupportinprogramminglanguagesandcompilers,sothosefeaturesaremishandledand/orpracticallyunusable,sothosefeaturesarelittleknownandlessindemand,andsothosefeatureslacksupportinprogramminglanguagesandcompilers.Tohelpbreakthatcircle,thosefeaturesarediscussedinthesenotesunderthefollowingheadings:RepresentableNumbers,NormalandSubnormal,InfiniteandNaN2Encodings,SpanandPrecision3-4Multiply-Accumulate,aMixedBlessing5ExceptionsinGeneral;RetrospectiveDiagnostics6Exception:InvalidOperation;NaNs7Exception:DividebyZero;Infinities10DigressiononDivisionbyZero;TwoExamples10Exception:Overflow14Exception:Underflow15DigressiononGradualUnderflow;anExample16Exception:Inexact18DirectionsofRounding18PrecisionsofRounding19TheBalefulInfluenceofBenchmarks;aProposedBenchmark20ExceptionsinGeneral,Reconsidered;aSuggestedScheme23RuminationsonProgrammingLanguages29AnnotatedBibliography30Insofarasthisisastatusreport,itissubjecttochangeandsupersedesversionswithearlierdates.Thisversionsupersedesonedistributedatapaneldiscussionof“Floating-PointPast,PresentandFuture”inaseriesofSanFranciscoBayAreaComputerHistoryPerspectivessponsoredbySunMicrosystemsInc.inMay1995.APost-Scriptversionisaccessibleelectronicallyas~wkahan/ieee754status/ieee754.ps.ThisdocumentwascreatedwithFrameMaker4.0.4WorkinProgress:LectureNotesontheStatusofIEEE754May31,19962:44pmPage2RepresentableNumbers:IEEE754specifiesthreetypesorFormatsoffloating-pointnumbers:Single(Fortran'sREAL*4,C'sfloat),(Obligatory),Double(Fortran'sREAL*8,C'sdouble),(Ubiquitous),andDouble-Extended(FortranREAL*10+,C'slongdouble),(Optional).(AfourthQuadruple-PrecisionformatisnotspecifiedbyIEEE754buthasbecomeadefactostandardamongseveralcomputermakersnoneofwhomsupportitfullyinhardwareyet,soitrunsslowlyatbest.)EachformathasrepresentationsforNaNs(Not-a-Number),±∞(Infinity),anditsownsetoffiniterealnumbersallofthesimpleform2k+1-Nnwithtwointegersn(signedSignificand)andk(unbiasedsignedExponent)thatrunthroughouttwointervalsdeterminedfromtheformatthus:K+1Exponentbits:1-2Kk2K.NSignificantbits:-2Nn2N.Thisconciserepresentation2k+1-Nn,uniquetoIEEE754,isdeceptivelysimple.Atfirstsightitappearspotentiallyambiguousbecause,ifniseven,dividingnby2(aright-shift)andthenadding1tokmakesnodifference.Wheneversuchanambiguitycouldariseitisresolvedbyminimizingtheexponentkandtherebymaximizingthemagnitudeofsignificandn;thisis“Normalization”which,ifitsucceeds,permitsaNormalnonzeronumbertobeexpressedintheform2k+1-Nn=±2k(1+f)withanonnegativefractionf1.BesidestheseNormalnumbers,IEEE754hasSubnormal(Denormalized)numberslackingorsuppressedinearliercomputerarithmetics;Subnormals,whichpermitUnderflowtobeGradual,arenonzeronumberswithanunnormalizedsignificandnandthesameminimalexponentkasisusedfor0:Subnormal2k+1-Nn=±2k(0+f)hask=2-2Kand0|n|2N-1,so0f1.Thus,whereearlierarithmeticshadconspicuousgapsbetween0andthetiniestNormalnumbers±22-2K,IEEE754fillsthegapswithSubnormalsspacedthesamedistanceapartasthesmallestNormalnumbers:Subnormals[---NormalizedNumbers---------------|||0-!-!-+-!-+-+-+-!-+-+-+-+-+-+-+-!---+---+---+---+---+---+---+---!--------||||||Powersof2:22-2K23-2K24-2K-+-ConsecutivePositiveFloating-PointNumbers-+-TableofFormats’Parameters:FormatBytesK+1NSingle4824Double81153Double-Extended≥10≥15≥64(Quadruple1615113)WorkinProgress:LectureNotesontheStatusofIEEE754May31,19962:44pmPage3IEEE754encodesfloating-pointnumbersinmemory(notinregisters)inwaysfirstproposedbyI.B.GoldberginComm.ACM(1967)105-6;itpacksthreefieldswithintegersderivedfromthesign,exponentandsignificandofanumberasfollows.Theleadingbitisthesignbit,0for+and1for-.ThenextK+1bitsholdabiasedexponent.ThelastNorN-1bitsholdthesignificand'smagnitude.Tosimplifythefollowingtable,thesignificandnisdissociatedfromitssignbitsothatnmaybetreatedasnonnegative.Encodingsof±2k+1-NnintoBinaryFields:Notethat+0and-0aredistinguishableandfollowobviousrulesspecifiedbyIEEE754eventhoughfloating-pointarithmeticalcomparisonsaystheyareequal;therearegoodreasonstodothis,someofthemdiscussedinmy1987paper“BranchCuts....”The

1 / 30
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功