f2003 part 1, floating point arithmetic standard 2006 included in 1539-1

Upload: itetejac

Post on 03-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    1/59

    October 4, 2006

    DRAFT Standard forFloating-Point Arithmetic P74

    Draft !"2"

    Modified at 12:44 on October 4, 2006

    S#on$or%Microprocessor Standards Committee

    Ab$tract% This standard specifies interchange and non-interchange formats and methods for binaryand decimal floating-point arithmetic in computer programming environments. Exception conditionsare defined and default handling of these conditions is specified.

    It is intended that an implementation of a floating-point system conforming to this standard can berealized entirely in softare! entirely in hardare! or in any combination of softare and hardare."or operations specified in the normative part of this standard! numerical results and exceptions areuni#uely determined by the values of the input data! se#uence of operations! and destinationformats! all under user control.

    &e'(ord$% computer! floating-point! arithmetic! rounding! format! interchange! number! binary!

    decimal! subnormal! $a$! significand! exponent.

    Copyright 2006 by the IEEEThree Park Avenue

    New York, New York 10016!""#, $%AA&& right' re'erve()Thi' (o*u+ent i' an unapprove( (rat o a propo'e( IEEE %tan(ar() A' 'u*h, thi' (o*u+ent i' 'ub-e*t to *hange) $%E ATY.$/ .N /I% 3e*au'e thi' i' an unapprove( (rat, thi' (o*u+ent +u't not be uti&i4e( or any*onor+an*e5*o+p&ian*e purpo'e') Per+i''ion i' hereby grante( or IEEE %tan(ar(' Co++ittee parti*ipant' torepro(u*e thi' (o*u+ent or purpo'e' o internationa& 'tan(ar(i4ation *on'i(eration) Prior to a(option o thi' (o*u+ent,in who&e or in part, by another 'tan(ar(' (eve&op+ent organi4ation per+i''ion +u't ir't be obtaine( ro+ the anager,

    %tan(ar(' Inte&&e*tua& Property, IEEE %tan(ar(' A*tivitie' 7epart+ent) .ther entitie' 'eeking per+i''ion to repro(u*ethi' (o*u+ent, in who&e or in part, +u't obtain per+i''ion ro+ the anager, %tan(ar(' Inte&&e*tua& Property, IEEE%tan(ar(' A*tivitie' 7epart+ent)

    IEEE %tan(ar(' A*tivitie' 7epart+entanager, %tan(ar(' Inte&&e*tua& Property88! 9oe' :ane

    Pi'*ataway, N; 0

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    2/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    Patent $tatement

    Attention i% called to t"e &o%%ibilit' t"at i#&le#entation of t"i% %tandard #a' re()ire )%e of %)b*ect #atterco+ered b' &atent rig"t%. ' &)blication of t"i% %tandard, no &o%ition i% ta-en it" re%&ect to t"e e/i%tence or+alidit' of an' &atent rig"t% in connection t"ereit". T"e %"all not be re%&on%ible for identif'ing &atent%or &atent a&&lication% for "ic" a licen%e #a' be re()ired to i#&le#ent an %tandard or for cond)ctingin()irie% into t"e legal +alidit' or %co&e of t"o%e &atent% t"at are bro)g"t to it% attention. A &atent "older or

    &atent a&&licant "a% filed a %tate#ent of a%%)rance t"at it ill grant licen%e% )nder t"e%e rig"t% it"o)tco#&en%ation or )nder rea%onable rate% and nondi%cri#inator', rea%onable ter#% and condition% to a&&licant%de%iring to obtain %)c" licen%e%. T"e #a-e% no re&re%entation a% to t"e rea%onablene%% of rate%, ter#%,and condition% of t"e licen%e agree#ent% offered b' &atent "older% or &atent a&&licant%. F)rt"er infor#ation#a' be obtained fro# t"e Standard% De&art#ent.

    )hange hi$tor'

    T"e folloing table %"o% t"e c"ange "i%tor' for t"i% doc)#ent.

    Version Date Author Description

    0.2 3 D Original content, &a%%ed fro# Da+id o)g" for %t'le%na#e% c"ange%.

    0.22 0$70706 D89 Re+i%ed b' Da+id 8 9a#e%:

    A&&lied MS te#&late% to e/i%ting te/t, incl)ding cro%%reference%. ncl)ded acron'# cla)%e and bibliogra&"' anne/. "anged to MS7 ;%"all, %"o)ld, #a', e/&ected< definition%. !ro+ided !AR %&ecified %co&e and &)r&o%e =re()ired>. A&&lied na#e% fro# &re+io)% #otion =ot"er% in t"e %a#e +ein>. Refor#atted indent% for clarit'. "anged b)llet li%t% to da%" li%t%. "anged n)#bered li%t% to: a> 1> i> ordering. ?nifor# italic% of=, y, and4) @i#ited font% to Arial, Ti#e% e Ro#an, S'#bol, o)rier. li#inated "i%torical anne/ =e/&ected to be +oted o)t>.

    1.0 0$71706 D Re%)lt% of %t'le re+ie 2006 9)l' 1.

    1.1 0$71706 D Re%)lt% of general #eeting 2006 9)l' 1: 1B Delete 5..2 Scaled&rod)ct o&eration, add A.. Scaled&rod)ct o&eration%

    1 Define #)lti&lee/ce&tion %e#antic% 21 larif' con+er%ion to %igned or )n%igned integer for#at 22 Red)ce reco##ended o&tion% for %ignaling a c"aracter %e()ence% 20 larif' con+er%ion to )n%igned integer for#at &lan A After ro)nding

    1.1.1 0$72$706 D Re%)lt% of %t'le re+ie 2006 9)l' 2$.

    1.1. 0B705706 ST Re%)lt% of %t'le re+ie 2006 A)g)%t .

    1.1.4 0B712706 ST Re%)lt% of general #eeting 2006 A)g)%t , and e#ail co##ent%.

    1.1.5 0B715706 D Re%)lt% of %t'le re+ie 2006 A)g)%t 15.

    1.1.6 0B71$706 D Re%)lt% of %t'le re+ie 2006 A)g)%t 1$.

    1.2 0712706 ST Re%)lt% of %t'le re+ie 2006 Se&te#ber 12 and general #eeting 2006Se&te#ber $.

    1.2.1 071$706 ST Re%)lt% of %t'le re+ie 2006 Se&te#ber 14.

    1.2. 0726706 ST Re%)lt% of %t'le re+ie 2006 Se&te#ber 26.

    1.2.4 10702706 ST Re%)lt% of %t'le re+ie 2006 Se&te#ber 2B.

    1.2.5 10704706 ST Re%)lt% of %t'le re+ie 2006 October .

    !age 2 Co)r co&'rig"t notice o)ld nor#all' a&&ear "ere.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    3/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    *ntrod+ction

    T"i% introd)ction i% not a &art of DRAFT Standard for Floating!oint Arit"#etic !$54.E

    T"i% %tandard i% a &rod)ct of t"e Floating!oint or-ing Gro)& of t"e Micro&roce%%or Standard%S)bco##ittee of t"e Standard% o##ittee of t"e o#&)ter Societ'. T"i% or- a% %&on%ored b' t"eTec"nical o##ittee on Micro&roce%%or% and Minico#&)ter%.

    !?R!OS: T"i% %tandard &ro+ide% a di%ci&line for &erfor#ing floating&oint co#&)tation t"at 'ield% re%)lt%inde&endent of "et"er t"e &roce%%ing i% done in "ardare, %oftare, or a co#bination of t"e to. Foro&eration% %&ecified in t"e nor#ati+e &art of t"i% %tandard, n)#erical re%)lt% and e/ce&tion% are )ni()el'deter#ined b' t"e +al)e% of t"e in&)t data, %e()ence of o&eration%, and de%tination for#at%, all )nder )%ercontrol.

    T"i% %tandard define% a fa#il' of co##erciall' fea%ible a'% for %'%te#% to &erfor# binar' and deci#alfloating&oint arit"#etic. A#ong t"e de%iderata t"at g)ided t"e for#)lation of t"i% %tandard ere

    a> Facilitate #o+e#ent of e/i%ting &rogra#% fro# di+er%e co#&)ter% to t"o%e t"at ad"ere to t"i%%tandard.

    b> n"ance t"e ca&abilitie% and %afet' a+ailable to )%er% and &rogra##er% "o, t"o)g" not e/&ert inn)#erical #et"od%, #a' ell be atte#&ting to &rod)ce n)#ericall' %o&"i%ticated &rogra#%.

    oe+er, e recogniHe t"at )tilit' and %afet' are %o#eti#e% antagoni%t%.c> nco)rage e/&ert% to de+elo& and di%trib)te rob)%t and efficient n)#erical &rogra#% t"at are

    &ortable, b' a' of #inor editing and reco#&ilation, onto an' co#&)ter t"at confor#% to t"i%%tandard and &o%%e%%e% ade()ate ca&acit'. "en re%tricted to a declared %)b%et of t"e %tandard, t"e%e&rogra#% %"o)ld &rod)ce identical re%)lt% on all confor#ing %'%te#%.

    d> !ro+ide direct %)&&ort for

    1> /ec)tionti#e diagno%i% of ano#alie%

    2> S#oot"er "andling of e/ce&tion%

    > nter+al arit"#etic at a rea%onable co%t

    e> !ro+ide for de+eloent of

    1> Standard ele#entar' f)nction% %)c" a% e/& and co%

    2> 8er' "ig" &reci%ion =#)ltiord> arit"#etic

    > o)&ling of n)#erical and %'#bolic algebraic co#&)tation

    f> nable rat"er t"an &recl)de f)rt"er refine#ent% and e/ten%ion%.

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    4/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    Partici#ant$

    At t"e ti#e t"i% %tandard a% co#&leted, t"e or-ing gro)& "ad t"e folloing #e#ber%"i&:

    Dan J)ra%, "air

    Ai-en, Ale/

    A&&legate, Matt"eaile', Da+id

    a%%, Ste+e

    "andar-ar, Dilee&

    "at, Ma"e%"

    indel, Da+id

    oldo, S'l+ie

    anon, Ste&"en

    arlo)g", Ste+en

    ornea, Mari)%

    oli%"a, Mi-e

    raford, 9o"n

    Darc', 9o%e&" D

    Da% Sar#a, Deb*itDa)#a%, Marc

    Da+i%, ob

    Da+i%, Mar-

    Del&, Dic-

    De##el, 9i#

    rle, Mar-

    Fa"#', o%%a#

    Fa%ano, 9.!.

    Fate#an, Ric"ard

    Feng, ric

    Ferg)%on, arren

    FitFlorea, Ale/

    Fo)rnier, @a)rent

    Freitag, "i&

    Godard, +an

    Golli+er, Roger

    G)%taf%on, Da+idac-, Mic"el

    arri%on, 9o"n

    a)%er, 9o"n

    ida, CoHo

    ind%, "ri%

    oare, Gra'don

    o)g", Da+id

    )c-, 9err'

    )ll, 9i#

    ngra%%ia, Mic"ael

    9a#e%, Da+id

    9a#e%, Ric-

    Ka"an, illia#Ka&ernic-, 9o"n

    Kar&in%-i, Ric"ard

    Kidder, 9eff

    Koe+, !la#en

    @i, Renang

    @i), J"i%")n Ale/

    Ma-, Ra'#ond

    Mar-%tein, !eter

    Mat)la, Da+id

    Mel()iond, G)illa)#e

    Mori, ob)'o%"i

    Morin, Ricardo

    edial-o+, ed

    el%on, raig

    Ober#an, St)art

    O-ada, 9on

    Oll#ann, an

    !ar-%, Mic"ael!itt#an, To#

    !o%t&i%c"il, ric

    Ried', 9a%on

    Sc"arH, ric

    Scott, Da+id

    SenHig, Don

    S"ara&o+, l'a

    S"earer, 9i#

    Si), Mic"ael

    S#it", Ron

    Ste+en%, ")c-

    Tang, !eter

    Ta'lor, !a#elaT"o#a%, 9i#

    T"o#&%on, randon

    T"ra%", end'

    Toda, eil

    Trong, Son Dao

    T%ai, @eonard

    T%en, "arle%

    T'de#an, Fred

    ang, @iang Kai

    e%tbroo-, Scott

    in-ler, Ste+e

    ood, Ant"on'

    Calcinal&, ?#it

    Je#-e, Fred

    Ji##er#ann, !a)l

    J)ra%, Dan

    !age 4 o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    5/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    T"e folloing #e#ber% of t"e balloting co##ittee +oted on t"i% %tandard. alloter% #a' "a+e +oted fora&&ro+al, di%a&&ro+al, or ab%tention.

    To e S)&&lied ' tc. tc.

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 5T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    6/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    Table of content$

    Table of content$

    1. O+er+ie ......................................................................................................................................................1.1 Sco&e....................................................................................................................................................

    1.2 ncl)%ion%.............................................................................................................................................1. /cl)%ion%............................................................................................................................................1.4 !)r&o%e.................................................................................................................................................1.5 @ang)agedefined7i#&le#entationdefined .........................................................................................1.6 Anne/e% .............................................................................................................................................10

    2. Reference% ..................................................................................................................................................11

    . Ter#% and definition% .................................................................................................................................12.1 onfor#ance le+el% ...........................................................................................................................12.2 Glo%%ar' of ter#% ...............................................................................................................................12

    4. Abbre+iation% and acron'#%........................................................................................................................15

    5. For#at% .......................................................................................................................................................165.1 O+er+ie: for#at% and confor#ance .................................................................................................165.2 S&ecification le+el% ............................................................................................................................1$5. Set% of floating&oint data ..................................................................................................................1$5.4 inar' interc"ange for#at encoding% .................................................................................................15.5 Deci#al interc"ange for#at encoding% ..............................................................................................205.6 oninterc"ange for#at% ...................................................................................................................2

    6. Mode% and ro)nding ...................................................................................................................................246.1 Mode %&ecification ............................................................................................................................246.2 Ro)nding direction #ode% .................................................................................................................24

    6.2.1 Ro)nding direction #ode% to neare%t .......................................................................................256.2.2 Directed ro)nding #ode% .........................................................................................................25

    $. O&eration% ..................................................................................................................................................26$.1 O+er+ie ...........................................................................................................................................26$.2 Deci#al e/&onent calc)lation ............................................................................................................26$. o#ogeneo)% generalco#&)tational o&eration% ...............................................................................2$

    $..1 General o&eration% ...................................................................................................................2$$..2 Deci#al o&eration ...................................................................................................................2B$.. logFor#at o&eration% ............................................................................................................2

    $.4 for#atOf generalco#&)tational o&eration% ......................................................................................2$.4.1 Arit"#etic o&eration% ..............................................................................................................2$.4.2 on+er%ion o&eration% for all for#at% ......................................................................................0$.4. on+er%ion o&eration% for binar' for#at% .............. .............. ............. ............ ............. ............ .0

    $.5 o#ogeneo)% ()ietco#&)tational o&eration%...................................................................................1$.5.1 Sign o&eration% ........................................................................................................................1

    $.5.2 Deci#al reencoding o&eration%...............................................................................................1$.6 Signalingco#&)tational o&eration% ...................................................................................................2

    $.6.1 o#&ari%on% ............................................................................................................................2$.6.2 /ce&tion %ignalingco#&)tational o&eration% ........................................................................

    $.$ onco#&)tational o&eration% ...........................................................................................................$.$.1 onfor#ance &redicate%...........................................................................................................$.$.2 General o&eration% ...................................................................................................................$.$. Deci#al o&eration ...................................................................................................................4$.$.4 O&eration% on %)b%et% of flag% .................................................................................................4$.$.5 O&eration% on all flag% .............................................................................................................5

    !age 6 o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    7/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    $.$.6 O&eration% on indi+id)al #ode% ..............................................................................................5$.$.$ O&eration% on all #ode% it" d'na#ic %&ecification ...............................................................6

    $.B Detail% of con+er%ion% fro# floating&oint to integer for#at% ............................................................6$. Detail% of o&eration% to ro)nd a floating&oint dat)# to integral +al)e ............... ............... ............ ....$$.10 Detail% of totalOrder &redicate..........................................................................................................B$.11 Detail% of co#&ari%on &redicate% .....................................................................................................B$.12 Detail% of con+er%ion beteen internal floating&oint and e/ternal c"aracter %e()ence% ............. ....40

    $.12.1 /ternal c"aracter %e()ence% re&re%enting Hero%, infinitie%, and a% ...... ....... ....... ...... ....... .41$.12.2 /ternal "e/adeci#al c"aracter %e()ence% re&re%enting finite n)#ber% ..... ....... ...... ...... ...... ..41$.12. /ternal deci#al c"aracter %e()ence% re&re%enting finite n)#ber% ......... .......... ......... ........... .42

    B. nfinit', a%, and %ign bit .........................................................................................................................4B.1 nfinit' arit"#etic...............................................................................................................................4B.2 O&eration% it" a% .......................................................................................................................4

    B.2.1 a encoding% in binar' for#at% ............................................................................................4B.2.2 a encoding% in deci#al for#at% ..........................................................................................44B.2. a &ro&agation .....................................................................................................................44

    B. T"e %ign bit ........................................................................................................................................44

    . Defa)lt e/ce&tion "andling .........................................................................................................................45

    .1 O+er+ie: e/ce&tion% and flag% .........................................................................................................45.2 n+alid o&eration ................................................................................................................................46. Di+i%ion b' Hero ................................................................................................................................46.4 O+erflo ...........................................................................................................................................46.5 ?nderflo ..........................................................................................................................................4$.6 ne/act ...............................................................................................................................................4$

    Anne/e%...........................................................................................................................................................4B

    Anne/ A =infor#ati+e> ibliogra&"'...............................................................................................................4B

    Anne/ =infor#ati+e> /&re%%ion e+al)ation ................................................................................................4 .1 O+er+ie..........................................................................................................................................4 .2 O&ti#iHation.....................................................................................................................................4

    . A%%ign#ent%......................................................................................................................................50

    Anne/ =infor#ati+e> idento #et"od% for e/&re%%ion e+al)ation............. .............. .............. ............ ...........51

    Anne/ D =infor#ati+e> le#entar' tran%cendental f)nction%............ ............... ............ ............ ............. ...........5

    Anne/ =infor#ati+e> Alternate e/ce&tion "andling #ode%...........................................................................55 .1 O+er+ie...........................................................................................................................................55.2 onre%)#able alternate e/ce&tion "andling #ode%..........................................................................55. Re%)#able alternate e/ce&tion "andling #ode%................................................................................56

    Anne/ F =infor#ati+e> Scaled !rod)ct O&eration%..........................................................................................5$

    Anne/ G =infor#ati+e> !rogra# deb)gging %)&&ort........................................................................................5B G.1 O+er+ie..........................................................................................................................................5B G.2 )#erical %en%iti+it'........................................................................................................................5B G. )#erical e/ce&tion%.......................................................................................................................5B G.4 !rogra##ing error%..........................................................................................................................5

    i$t of fig+re$

    Fig)re 5.13inar' interc"ange floating&oint for#at.....................................................................................1

    Fig)re 5.23Deci#al interc"ange floating&oint for#at%.................................................................................20

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age $T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    8/59

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    9/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    DRAFT Standard forFloating-Point Arithmetic P74

    !" Oerie( !"0

    !"! Sco#e!"!"0

    T"i% %tandard %&ecifie% interc"ange and noninterc"ange for#at% and #et"od% for binar' and deci#al floating&oint arit"#etic in co#&)ter &rogra##ing en+iron#ent%. /ce&tion condition% are defined and defa)lt"andling of t"e%e condition% i% %&ecified.

    t i% intended t"at an i#&le#entation of a floating&oint %'%te# confor#ing to t"i% %tandard can be realiHedentirel' in %oftare, entirel' in "ardare, or in an' co#bination of %oftare and "ardare. t i% t"een+iron#ent t"e )%er of t"e %'%te# %ee% t"at confor#% or fail% to confor# to t"i% %tandard. ardareco#&onent% t"at re()ire %oftare %)&&ort to confor# %"all not be %aid to confor# a&art fro# %)c" %oftare.

    !"2 *ncl+$ion$!"2"0

    T"i% %tandard %&ecifie%:

    L For#at% for binar' and deci#al floating&oint data, for co#&)tation and data interc"ange.

    L Addition, %)btraction, #)lti&lication, di+i%ion, f)%edM)lti&l'Add, %()areRoot, co#&are, and ot"ero&eration%.

    L on+er%ion% beteen integer and floating&oint for#at%.

    L on+er%ion% beteen different floating&oint for#at%.

    L on+er%ion% beteen floating&oint data in internal for#at% and e/ternal re&re%entation% a% c"aracter%e()ence%.

    L Floating&oint e/ce&tion% and t"eir "andling, incl)ding data t"at are not n)#ber% =a%>.

    !". /cl+$ion$!"."0

    T"i% %tandard doe% not %&ecif':

    L For#at% of integer% and e/ternal re&re%entation% of n)#ber% a% c"aracter %e()ence%.

    L nter&retation of t"e %ign and %ignificand field% of a%.

    !"4 P+r#o$e!"4"0

    T"i% %tandard &ro+ide% a di%ci&line for &erfor#ing floating&oint co#&)tation t"at 'ield% re%)lt% inde&endentof "et"er t"e &roce%%ing i% done in "ardare, %oftare, or a co#bination of t"e to. For o&eration% %&ecifiedin t"e nor#ati+e &art of t"i% %tandard, n)#erical re%)lt% and e/ce&tion% are )ni()el' deter#ined b' t"e +al)e%

    of t"e in&)t data, %e()ence of o&eration%, and de%tination for#at%, all )nder )%er control.

    !" ang+age-defined1im#lementation-defined !""0

    T"i% %tandard doe% not define all a%&ect% of a confor#ing &rogra##ing en+iron#ent. S)c" be"a+ior %"o)ldbe defined b' a &rogra##ing lang)age definition %)&&orting t"i% %tandard, if a+ailable, and ot"eri%e b' a&artic)lar i#&le#entation. So#e &rogra##ing lang)age% #a' c"oo%e to lea+e %o#e be"a+ior% toi#&le#entation% to define.

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    10/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    Language-definedbe"a+ior %"o)ld be defined b' a &rogra##ing lang)age %tandard %)&&orting t"i% %tandard.T"en all i#&le#entation% confor#ing bot" to t"i% floating&oint %tandard and to t"at lang)age %tandard illbe"a+e identicall' it" re%&ect to %)c" lang)agedefined be"a+ior%. @ang)age% t"at a%&ire toardre&rod)cible re%)lt% on all &latfor#% are e/&ected to %&ecif' #ore be"a+ior% t"an lang)age% t"at a%&ire toard#a/i#)# &erfor#ance on all &latfor#%.

    eca)%e t"i% %tandard re()ire% facilitie% t"at are not c)rrentl' a+ailable in co##on &rogra##ing lang)age%,

    %)c" lang)age% #ig"t not be able to f)ll' %)&&ort t"i% %tandard if t"e' are no longer e+ol+ing t"e#%el+e% a%%tandard%. f t"e lang)age can be e/tended b' a f)nction librar' or cla%% or &ac-age to &ro+ide a confor#ingen+iron#ent, t"en t"at e/ten%ion %"o)ld define all t"e lang)agedefined be"a+ior% t"at o)ld nor#all' bedefined b' a lang)age %tandard.

    Implementation-defined be"a+ior i% defined b' a %&ecific i#&le#entation of a %&ecific &rogra##ingen+iron#ent confor#ing to t"i% %tandard. #&le#entation% define be"a+ior% not %&ecified b' t"i% %tandard norb' an' rele+ant &rogra##ing lang)age %tandard or &rogra##ing lang)age e/ten%ion.

    onfor#ance to t"i% %tandard i% a &ro&ert' of a %&ecific i#&le#entation of a %&ecific &rogra##ingen+iron#ent, rat"er t"an of a lang)age %&ecification.

    oe+er a lang)age %&ecification co)ld al%o be %aid to confor# to t"i% %tandard if it ere con%tr)cted %o t"ate+er' confor#ing i#&le#entation of t"at lang)age al%o confor#ed a)to#aticall' to t"i% %tandard.

    !"6 Annee$!"6"0

    T"e nor#ati+e &art of t"i% %tandard i% acco#&anied b' %e+eral nonnor#ati+e anne/e%:

    L Anne/and Anne/ contain reco##endation% for &rogra##ing lang)age%.

    L Anne/ D,Anne/ ,Anne/Fand Anne/G incor&orate t"e or-ing gro)&% con%en%)% on direction%t"at f)t)re %tandard re+i%ion% %"o)ld addre%%. ' &ro+iding t"e%e in &reli#inar' for#, t"e or-inggro)& "o&e% t"at lang)age de%igner%, %tandard% bodie%, and i#&le#enter% ill de+elo& andi#&le#ent %&ecification% t"at a&&lication &rogra##er% can e/&loit.

    !age 10 o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    11/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    2" Reference$ 2"0

    T"e folloing referenced doc)#ent% are indi%&en%able for t"e a&&lication of t"i% %tandard:

    AS7 Std $54N1B5, Standard for inar' Floating!oint Arit"#etic. 1

    SO7 B, Second edition 11201, !rogra##ing lang)age%%2

    1IEEE publications are available from the Institute of Electrical and Electronics Engineers, 445 Hoes Lane, P.O. Box1331, Piscataway, NJ 08855-1331, USA.2ISO publications are available from the ISO Central Secretariat, Case Postale 56, 1 rue de Varemb, CH-1211,Genve 20, Switzerland/Suisse. ISO publications are also available in the United States from the Sales Department,American National Standards Institute, 11 West 42nd Street, 13th Floor, New York, NY 10036, USA.

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 11T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    12/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    ." Term$ and definition$ ."0

    ."! )onformance leel$."!"0

    Se+eral -e'ord% are )%ed to differentiate beteen different le+el% of re()ire#ent% and o&tionalit', a%follo%:

    3.1.1 expected: De%cribe% t"e be"a+ior of t"e "ardare or %oftare in t"e de%ign #odel% a%%)#ed b' t"i%%&ecification. Ot"er "ardare and %oftare de%ign #odel% #a' al%o be i#&le#ented.

    3.1.2 may: ndicate% a co)r%e of action &er#i%%ible it"in t"e li#it% of t"e %tandard it" no i#&lied&reference =#a'P #ean% i% &er#itted toP>.

    3.1.3 shall:ndicate% #andator' re()ire#ent% %trictl' to be folloed in order to confor# to t"e %tandard andfro# "ic" no de+iation i% &er#itted =%"allP #ean% i% re()ired toP>.

    3.1. should:ndicate% t"at a#ong %e+eral &o%%ibilitie%, one i% reco##ended a% &artic)larl' %)itable, it"o)t#entioning or e/cl)ding ot"er%Q or t"at a certain co)r%e of action i% &referred b)t not nece%%aril' re()iredQ ort"at =in t"e negati+e for#> a certain co)r%e of action i% de&recated b)t not &ro"ibited =%"o)ldP #ean% i%reco##ended toP>.

    ."2 lo$$ar' of term$."2"0

    3.2.1 !asic format: One of t"e fi+e %et% of floating&oint re&re%entation%, t"ree binar' and to deci#al,"o%e encoding% are %&ecified b' t"i% %tandard, and "ic" are a+ailable for arit"#etic.

    3.2.2 !iased exponent: T"e %)# of t"e e/&onent and a con%tant =bia%> c"o%en to #a-e t"e bia%ed e/&onent%range nonnegati+e.

    3.2.3 !inary floating-point num!er:A floating&oint n)#ber it" radi/ to.

    3.2. canonical encoding:T"e &referred encoding of a floating&oint re&re%entation in a for#at. A&&lied todeclet%, %ignificand% of finite n)#ber%, infinitie%, and a%, e%&eciall' in deci#al for#at%.

    3.2." cohort:n a gi+en for#at, t"e %et of re&re%entation% of floating&oint n)#ber% it" t"e %a#e n)#erical+al)e. 0 and 0 are in %e&arate co"ort%.

    3.2.#computational operation: An o&eration &rod)cing a floating&oint re%)lt or ca&able of %ignaling afloating&oint e/ce&tion. o#&ari%on% are co#&)tational o&eration%.

    3.2.$ correct rounding:T"i% %tandard% #et"od of con+erting an infinitel' &reci%e re%)lt to a floating&ointn)#ber, a% deter#ined b' t"e &re+ailing ro)nding direction #ode. A floating&oint n)#ber %o obtained i% %aidto be correctl' ro)nded.

    3.2.% decimal floating-point num!er: A floating&oint n)#ber it" radi/ ten.

    3.2.& declet: An encoding of t"ree deci#al digit% into ten bit% )%ing t"e den%el'&ac-ed deci#al encoding%c"e#e. Of t"e 1024 &o%%ible declet%, 1000 canonical declet% are &rod)ced b' co#&)tational o&eration%,"ile 24 noncanonical declet% are not &rod)ced b' co#&)tational o&eration%, b)t are acce&ted in o&erand%.

    3.2.1' denormali(ed num!er:See %)bnor#al n)#ber.

    3.2.11 destination: T"e location for t"e re%)lt of an o&eration )&on one or #ore o&erand%. A de%tination #a'be eit"er e/&licitl' de%ignated b' t"e )%er or i#&licitl' %)&&lied b' t"e %'%te# =for e/a#&le, inter#ediatere%)lt% in %)be/&re%%ion% or arg)#ent% for &roced)re%>. So#e lang)age% &lace t"e re%)lt% of inter#ediatecalc)lation% in de%tination% be'ond t"e )%er% controlQ nonet"ele%%, t"i% %tandard define% t"e re%)lt of ano&eration in ter#% of t"at de%tination% for#at and t"e o&erand% +al)e%.

    3.2.12 exception:An e+ent t"at occ)r% "en an o&eration "a% no o)tco#e %)itable for e+er' rea%onablea&&lication. T"at o&eration #ig"t %ignal one or #ore e/ce&tion% b' in+o-ing t"e defa)lt or, if e/&licitl're()e%ted, a lang)agedefined alternate "andling. ote t"at e+ent,P e/ce&tion,P and %ignalP are defined indi+er%e a'% in different &rogra##ing en+iron#ent%.

    !age 12 o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    13/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    3.2.13 exponent:T"e co#&onent of a finite floating&oint re&re%entation t"at %ignifie% t"e integer &oer to"ic" t"e radi/ i% rai%ed in deter#ining t"e +al)e of t"at floating&oint re&re%entation. T"e e/&onent e i% )%ed"en t"e %ignificand i% regarded a% an integer digit and fraction field, and t"e e/&onent >i% )%ed "en t"e%ignificand i% regarded a% an integerQ e>pN1 "erepi% t"e %ignificand lengt" in digit%.3.2.1 extended format: A noninterc"ange for#at it" ider &reci%ion and range t"at e/tend% a %)&&ortedba%ic for#at.

    3.2.1" external character se)uence:A re&re%entation of a n)#ber or a a% a %e()ence of c"aracter%,incl)ding t"e c"aracter %e()ence% in floating&oint literal% in &rogra# te/t.

    3.2.1# floating-point datum: A floating&oint n)#ber or nonn)#ber =a> t"at i% re&re%entable in afloating&oint for#at. n t"i% %tandard, a floating&oint dat)# i% not ala'% di%ting)i%"ed fro# it%re&re%entation or encoding.

    3.2.1$ floating-point num!er:A finite or infinite n)#ber t"at i% re&re%entable in a floating&oint for#at. Afloating&oint dat)# t"at i% not a a. All floating&oint n)#ber%, incl)ding Hero% and infinitie%, are %igned.

    3.2.1% floating-point representation:An )nencoded #e#ber of a floating&oint for#at, re&re%enting a finiten)#ber, a %igned infinit', or a ()iet or %ignaling a. A re&re%entation of a finite n)#ber "a% t"reeco#&onent%: a %ign, an e/&onent, and a %ignificandQ it% n)#erical +al)e i% t"e %igned &rod)ct of it% %ignificandand it% radi/ rai%ed to t"e &oer of it% e/&onent.

    3.2.1& format: A %et of re&re%entation% of n)#erical +al)e% and %'#bol%, &er"a&% acco#&anied b' anencoding.

    3.2.2' fused*ultiplyAdd:T"e o&eration f)%edM)lti&l'Add==,y,4> co#&)te% ==Uy>4a% if it" )nbo)ndedrange and &reci%ion, ro)nding onl' once to t"e de%tination for#at.

    3.2.21 generic operation:An o&eration t"at can ta-e o&erand% of +ario)% for#at%, for "ic" t"e for#at% oft"e re%)lt% #a' de&end on t"e for#at% of t"e o&erand%.

    3.2.22 homogeneous operation: An o&eration of t"i% %tandard t"at ta-e% o&erand% and ret)rn% re%)lt% all int"e %a#e for#at.

    3.2.23 mode: An i#&licit &ara#eter to o&eration% of t"i% %tandard, "ic" t"e )%er #a' %et, te%t, %a+e, andre%tore. T"e ter# #ode #a' refer to t"e #ode &ara#eter =a% in Vro)nding direction #odeV> or it% +al)e =a% inVro)ndToardJero #odeV>.

    3.2.2 +a+:ot a )#ber, a %'#bolic floating&oint dat)#. T"ere are to t'&e% of a re&re%entation%:

    ()iet and %ignaling. Mo%t o&eration% &ro&agate )uiet +a+% it"o)t %ignaling e/ce&tion%, and %ignal t"ein+alid e/ce&tion "en gi+en a signaling +a+o&erand.

    3.2.2" narro,er,ider format: f t"e %et of floating&oint n)#ber% of one for#at i% a &ro&er %)b%et ofanot"er for#at, t"e fir%t i% called narroer and t"e %econd ider. T"e ider for#at #ig"t "a+e greater&reci%ion, range, or =)%)all'> bot".

    3.2.2# non-computational operation: An o&eration &rod)cing no floating&oint re%)lt and ne+er %ignalingan' floating&oint e/ce&tion.

    3.2.2$ normal num!er: For a &artic)lar for#at, a finite nonHero floating&oint n)#ber it" #agnit)degreater t"an or e()al to a #ini#)# be+in+al)e. or#al n)#ber% can )%e t"e f)ll &reci%ion a+ailable in afor#at. n t"i% %tandard, Hero i% neit"er nor#al nor %)bnor#al.

    3.2.2% payload:T"e diagno%tic infor#ation contained in a a, encoded in &art of it% trailing %ignificand

    field.

    3.2.2& precision: T"e n)#ber of digit% t"at can be re&re%ented in a for#at, or t"e n)#ber of digit% to "ic" are%)lt i% ro)nded.

    3.2.3' preailing mode:T"e +al)e of a #ode go+erning a &artic)lar in%tance of e/ec)tion of a co#&)tationalo&eration of t"i% %tandard. @ang)age% %&ecif' "o t"e &re+ailing #ode i% deter#ined.

    3.2.31 )uantum: T"e ()ant)# of a finite floating&oint re&re%entation i% t"e +al)e of a )nit in t"e la%t&o%ition of it% %ignificand. T"i% i% e()al to t"e radi/ rai%ed to t"e e/&onent >.

    3.2.32 )uiet operation:An o&eration t"at ne+er %ignal% an' floating&oint e/ce&tion.

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 1T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    14/59

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    15/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    4" Abbreiation$ and acron'm$

    T"i% doc)#ent contain% no abbre+iation% and acron'#% t"at are not defined el%e"ere.

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 15T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    16/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    " Format$ "0

    "! Oerie(% format$ and conformance "!"0

    T"i% cla)%e define% %e+eral -ind% of %tandard floating&oint for#at%, in to radice%, 2 and 10. All t"e for#at%%&ecified b' t"i% %tandard are fi/edidt". T"e &reci%ion and range of a fi/edidt" for#at are deter#inable

    fro# t"e &rogra# te/t, and t"e corre%&onding encoding i% )%)all' defined %o t"at all #e#ber% "a+e t"e %a#e%iHe in %torage.

    For#at% defined b' t"i% %tandard are interc"ange or noninterc"ange:

    / interchange formatsare for#at% it" encoding% defined in t"i% %tandard. T"e' are idel' a+ailablefor %torage and for data interc"ange a#ong &latfor#%. T"e for#at na#e% )%ed in t"i% %tandard are not)%)all' t"o%e )%ed in &rogra##ing en+iron#ent%. nterc"ange for#at% defined b' t"i% %tandard areba%ic or %torage:

    L !asic formats are interc"ange for#at%, a+ailable for arit"#etic. T"i% %tandard define% t"reeba%ic binar' floating&oint for#at% in lengt"% of 2, 64, and 12B bit%, and to ba%ic deci#alfloating&oint for#at% in lengt"% of 64 and 12B bit%. A &rogra##ing en+iron#ent confor#% tot"i% %tandard, in a &artic)lar radi/, b' i#&le#enting one or #ore of t"e ba%ic for#at% of t"atradi/. T"e c"oice of %tandard for#at% i% lang)agedefined or, if t"e rele+ant lang)age %tandardi% %ilent or defer% to t"e i#&le#entation, i#&le#entationdefined. A confor#ing

    i#&le#entation of a ba%ic for#at %"all:

    L &ro+ide #ean% to initialiHe and %tore t"at for#at,

    L &ro+ide all t"e o&eration% of t"i% %tandard for t"at for#at,

    L &ro+ide con+er%ion% beteen t"at ba%ic for#at and all ot"er i#&le#ented %tandard for#at%.

    L storage formats are narro interc"ange for#at%. T"i% %tandard define% one binar' %toragefloating&oint for#at of 16 bit% lengt", and one deci#al %torage floating&oint for#at of 2 bit%lengt". To %)&&ort a %torage for#at, t"i% %tandard onl' re()ire% t"at con+er%ion% be &ro+idedbeteen t"at %torage for#at and all ot"er %)&&orted for#at% of t"e %a#e radi/. @ang)age%&er#itting co#&)tation )&on %torage for#at% %"o)ld &erfor# %)c" co#&)tation% in iderfor#at%.

    / non-interchange formats are for#at% it" no encoding% defined in t"i% %tandard. one are re()iredb' t"i% %tandard. f i#&le#ented t"e' are a+ailable for arit"#etic, b)t t"e' #ig"t not be %)itable for

    interc"anging data a#ong &latfor#%.

    !age 16 o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    17/59

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    18/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    T"e +al)e% of t"e%e &ara#eter% for eac" interc"ange for#at are gi+en in Table 2Q con%traint% on t"e%e&ara#eter% for e/tended for#at% are gi+en in Table $. Table 2 refer% to interc"ange for#at% b' t"e n)#ber ofbit% in t"eir encoding. it"in eac" for#at, t"e folloing floating&oint data %"all be &ro+ided:

    L Signed Hero and nonHero floating&oint n)#ber% of t"e for# =N1>'UbeU+, "ere:

    L 'i% 0 or 1

    L ei% an' integer e+inZeZe+a=L +i% a n)#ber re&re%ented b' a digit %tring of t"e for#

    (0[(1(2@(p?1"ere (i i% an integer digit 0Z(i\b=t"erefore 0Z+\b>L To infinitie%, Y and NY

    L a

    T"e%e are t"e onl' floating&oint data &ro+ided.

    n t"e foregoing de%cri&tion, t"e %ignificand +i% +ieed in a %cientific for#, it" t"e radi/ &oint i##ediatel'folloing t"e fir%t digit. t i% al%o con+enient for %o#e &)r&o%e% to +ie t"e %ignificand a% an integerQ t"en t"efinite floating&oint n)#ber% are de%cribed t")%:

    L Signed Hero and nonHero floating&oint n)#ber% of t"e for# =N1>'Ub>U*, "ere

    L 'i% 0 or 1

    L >i% an' integer e+inZ>p?1Ze+a=L *i% a n)#ber re&re%ented b' a digit %tring of t"e for#

    (0(1(2@(p?1"ere (ii% an integer digit 0 Z (i\ b=*i% t"erefore an integer it" 0 Z *\ bp>.

    T"i% +ie of t"e %ignificand a% an integer, *, it" it% corre%&onding e/&onent >, de%cribe% e/actl' t"e %a#e %etof Hero and nonHero floating&oint n)#ber% a% t"e +ie in %cientific for#. =For finite floating&oint n)#ber%,e>pN1 and +*Ub1Np.>T"e %#alle%t &o%iti+e nor+a& floating&oint n)#ber i% be+in and t"e large%t i% be+a=U=b?b1Np>. T"e nonHerofloating&oint n)#ber% for a for#at it" #agnit)de le%% t"an be+in are called 'ubnor+a& beca)%e t"eir#agnit)de% lie beteen Hero and t"e %#alle%t nor#al #agnit)de. S)bnor#al n)#ber% are di%ting)i%"ed fro#nor#al n)#ber% beca)%e of red)ced &reci%ion and, in binar', beca)%e of different encoding #et"od%. +er'finite floating&oint n)#ber i% an integral #)lti&le of t"e %#alle%t %)bnor#al #agnit)de be+inUb1Np.

    For a floating&oint n)#ber t"at "a% t"e +al)e Hero, t"e %ign bit '&ro+ide% an e/tra bit of infor#ation.Alt"o)g" all for#at% "a+e di%tinct re&re%entation% for 0 and N0, t"e %ign of a Hero i% %ignificant in %o#ecirc)#%tance%, %)c" a% di+i%ion b' Hero, b)t not in ot"er% =%eeB.>. inar' interc"ange for#at% "a+e *)%t onere&re%entation eac" for 0 and 0, b)t deci#al for#at% "a+e #an'. n t"i% %tandard, 0 and Y are rittenit"o)t a %ign "en t"e %ign i% not i#&ortant.

    0a!le 2Interchange format parameters defining floating-point num!ers0

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    19/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    "4 3inar' interchange format encoding$ "4"0

    ac" floating&oint n)#ber "a% *)%t one encoding in a binar' interc"ange for#at. To #a-e t"e encoding)ni()e, in ter#% of t"e &ara#eter% in 5.1,t"e +al)e of t"e %ignificand +i% #a/i#iHed b' decrea%ing e)ntileit"er ee+in or +]1. After t"i% nor#aliHation &roce%% i% done, if ee+in and +\1, t"e floating&ointn)#ber i% %)bnor#al. S)bnor#al n)#ber% =and Hero> are encoded it" a re%er+ed bia%ed e/&onent +al)e.

    Floating&oint data in t"e binar' interc"ange for#at% are encoded in t"e folloing t"ree field% ordered a%%"on in Fig)re 5.1:

    a> 1bit %ign %

    b> wbit bia%ed e/&onentE ebia'c> =tp?1>bit trailing %ignificand digit %tring T(1 (2^(pN1Q t"e leading bit of t"e %ignificand, (0, i%

    i#&licitl' encoded in t"e bia%ed e/&onentE)

    Fig+re "!3inar' interchange floating-#oint format

    MS i% #o%t %ignificant bitQ @S i% lea%t %ignificant bit. T"e +al)e% of w, bia', and t for t"e binar'interc"ange for#at% are li%ted in Table .

    T"e range of t"e encoding% bia%ed e/&onentE%"all incl)de:

    L +er' integer beteen 1 and 2wN2, incl)%i+e, to encode nor#al n)#ber%L T"e re%er+ed +al)e 0 to encode _0 and %)bnor#al n)#ber%

    L T"e re%er+ed +al)e 2wN1 to encode _Y and a%.T"e re&re%entation r of t"e floating&oint dat)#, and +al)e vof t"e floating&oint dat)# re&re%ented, areinferred fro# t"e con%tit)ent field% t")%:

    a> fE 2wN1 and T0, t"en ri% (a or %a and vi% a regardle%% of %.b> fE 2wN1 and T0 , t"en rand v =N1>%UY.c> f 1ZEZ2wN2, t"en ri% =%, =E?bia'>, =121NpUT>>Q

    t"e +al)e of t"e corre%&onding floating&oint n)#ber i% v =N1>%U2E?bia' U=121NpUT>Qt")% nor#al n)#ber% "a+e an i#&licit leading %ignificand bit of 1.

    d> fE0 and T0, t"en ri% =%, e+in, =021NpUT>>Qt"e +al)e of t"e corre%&onding floating&oint n)#ber i% v =N1>%U2e+in U=021NpUT>Qt")% %)bnor#al n)#ber% "a+e an i#&licit leading %ignificand bit of 0.

    e> fE0 and T0 , t"en ri% =%, e+in, 0> and v =N1>%U0 =%igned Hero, %eeB.>.Table .3inar' interchange format encoding #arameter$0

    =ormat name parameter !inary1# !inary32 !inary# !inary12%

    Storage width L 16 32 64 128

    Trailing significand width t 10 23 52 112

    Biased exponent field width w 5 8 11 15

    Bias E-e 15 127 1023 16383

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 1T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

    d&..................................................................................d

    p-&E

    '....................E

    w-&

    t( p)& bits& bit MS* wbits +S*MS*+S*T

    ,trailing significandE

    ,biased exponentS

    ,sign

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    20/59

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    21/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    T"e +al)e% of w, bia', and t for t"e deci#al interc"ange for#at% are li%ted in Table4:

    0a!le Decimal interchange format encoding parameters0

    =ormat name parameter decimal32 decimal# decimal12%

    Storage idt" L 2 64 12B

    Trailing %ignificand idt" t 20 50 110

    o#bination field idt" w5 11 1 1$

    ia% E> 101 B 61$6

    T"e re&re%entation r of t"e floating&oint dat)#, and +al)e v of t"e floating&oint dat)# re&re%ented, areinferred fro# t"e con%tit)ent field%, t")%:

    a> f B0t"ro)g" B8are 11111, t"en vi% a regardle%% of %. F)rt"er#ore, if B5i% 1, t"en ri% %aQot"eri%e r i% (a. T"e re#aining bit% of Bare ignored, and Tcon%tit)te% t"e a% &a'load,"ic" can be )%ed to di%ting)i%" +ario)% a%.

    T"e a &a'load i% encoded %i#ilarl' to finite n)#ber% de%cribed belo, it" B treated a% t"o)g"

    all bit% ere Hero. T"e &a'load corre%&ond% to t"e %ignificand of finite n)#ber%, inter&reted a% aninteger it" a #a/i#)# +al)e of 10=U;>1, and t"e e/&onent i% ignored =it i% treated a% if it ereHero>. A a i% in it% &referred =canonical> re&re%entation if t"e bit% B6t"ro)g" Bw4 are Hero andt"e encoding of t"e &a'load i% canonical.

    b> f B0t"ro)g" B4are 11110 t"en rand v =1>%UY. T"e +al)e% of t"e re#aining bit% in B, and T, are

    ignored. T"e to canonical re&re%entation% of infinit' "a+e bit% B5t"ro)g" B4 0, and T 0.

    c> For finite n)#ber%, ri% =%,Ebia', C> and v =1>%U10=Ebia'>UC, "ere Ci% t"e concatenation oft"e leading %ignificand digit fro# t"e co#bination field Band t"e trailing %ignificand field Tand t"ebia%ed e/&onentEi% encoded in t"e co#bination field. T"e encoding it"in t"e%e field% de&end% on"et"er t"e %ignificand )%e% t"e deci#al or t"e binar' encoding.

    1> f t"e %ignificand )%e% t"e (e*i+a&encoding, t"en t"e lea%t %ignificant wbit% of t"e e/&onent areB5 t"ro)g" Bw4. T"e #o%t %ignificant to bit% of t"e bia%ed e/&onent and t"e deci#al digit%tring (0(1^(p1of t"e %ignificand are for#ed fro# bit% B0t"ro)g" B4and Ta% follo%:

    i> "en t"e fir%t fi+e bit% of Bare 110// or 1110/, t"e leading %ignificand digit (0i% BB4, a+al)e B or , and t"e leading bia%ed e/&onent bit% are 2B2B, a +al)e 0, 1, or 2.

    ii> "en t"e fir%t fi+e bit% of B are 0//// or 10///, t"e leading %ignificand digit (0 i%4B22BB4, a +al)e in t"e range 0^$, and t"e leading bia%ed e/&onent bit% are 2B0B1, a+al)e 0, 1, or 2. on%e()entl' if Ti% 0 and t"e fir%t fi+e bit% of Bare 00000, 01000, or10000, t"en v =N1>%U0.

    T"e p1U; deci#al digit% (1^(p1are encoded b' T"ic" contain%;declet% encoded inden%el'&ac-ed deci#al.

    A canonical %ignificand "a% onl' canonical declet%, a% %"on in Table% 5and6.o#&)tationalo&eration% &rod)ce onl' t"e 1000 canonical declet%, b)t al%o acce&t t"e 24 noncanonical declet%in o&erand%.

    2> Alternati+el', if t"e %ignificand )%e% t"e binaryencoding, t"en

    i> f B0and B1toget"er are one of 00, 01, or 10, t"en t"e bia%ed e/&onentEi% for#ed fro# B0t"ro)g" Bw1and t"e %ignificand i% for#ed fro# bit% Bw2t"ro)g" t"e end of t"e encoding=incl)ding T>.

    ii> f B0and B1toget"er are 11 and B2and Btoget"er are one of 00, 01, or 10, t"en t"e bia%ede/&onentEi% for#ed fro# B2t"ro)g" Bwand t"e %ignificand i% for#ed b' &refi/ing t"e 4bit% =BBw4> to T.

    n bot" ca%e% i> and ii>, t"e #a/i#)# +al)e of t"e binar'encoded %ignificand i% t"e %a#e a% t"atof t"e e()i+alent deci#alencoded %ignificandQ t"at i%, 10=U;1>1 =or 10=U;>1 "en Ti% )%ed a%t"e &a'load of a a>. f t"e +al)e e/ceed% t"e #a/i#)#, t"e %ignificand *i% noncanonical

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 21T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    22/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    and t"e +al)e )%ed for *i% Hero. o#&)tational o&eration% &rod)ce onl' canonical %ignificand%,b)t al%o acce&t noncanonical %ignificand% in o&eration%.

    Decoding densely-pac>ed decimal:Table5 decode% a declet, it" 10 bit% !9';to !9&; into deci#al digit%d91; d92; d93;. T"e fir%t col)#n i% in binar' and an /P denote% don`t careP. T")% all 1024 &o%%ible 10bit&attern% %"all be acce&ted and #a&&ed into 1000 &o%%ible digit co#bination% it" %o#e red)ndanc'.

    Table Decoding !0-bit den$el'-#ac5ed decimal to . decimal digit$0

    !9#; !9$; !9%; !93; !9; d91; d92; d93;

    0 / / / / 4b=0> 2b=1> b=2> 4b=> 2b=4> b=5> 4b=$> 2b=B> b=>

    1 0 0 / / 4b=0> 2b=1> b=2> 4b=> 2b=4> b=5> B b=>

    1 0 1 / / 4b=0> 2b=1> b=2> B b=5> 4b=$> 2b=B> b=>

    1 1 0 / / B b=2> 4b=> 2b=4> b=5> 4b=$> 2b=B> b=>

    1 1 1 0 0 B b=2> B b=5> 4b=$> 2b=B> b=>

    1 1 1 0 1 B b=2> 4b=> 2b=4> b=5> B b=>

    1 1 1 1 0 4b=0> 2b=1> b=2> B b=5> B b=>

    1 1 1 1 1 B b=2> B b=5> B b=>

    ?ncoding densely-pac>ed decimal:Table 6 encode% deci#al digit% d91;, d92;, and d93;, eac" "a+ing 4 bit%"ic" can be e/&re%%ed b' a %econd %)b%cri&t d91':3; d92':3;, and d93':3; "ere bit 0 i% t"e #o%t %ignificant andbit t"e lea%t %ignificant, into a declet, it" 10 bit% !9'; to !9&;. o#&)tational o&eration% generate onl' t"e1000 canonical 10bit &attern% defined b' Table6.

    Table 6/ncoding . decimal digit$ to !0-bit den$el'-#ac5ed decimal0

    d91'; d92'; d93'; !9'; !91; !92; !93; !9; !9"; !9#; !9$; !9%; !9&;

    0 0 0 d=1,1:> d=2,1:> 0 d=,1:>

    0 0 1 d=1,1:> d=2,1:> 1 0, 0, d=,>

    0 1 0 d=1,1:> d=,1:2>, d=2,> 1 0, 1, d=,>

    0 1 1 d=1,1:> 1, 0, d=2,> 1 1, 1, d=,>

    1 0 0 d=,1:2>, d=1,> d=2,1:> 1 1, 0, d=,>

    1 0 1 d=2,1:2>, d=1,> 0, 1, d=2,> 1 1, 1, d=,>

    1 1 0 d=,1:2>, d=1,> 0, 0, d=2,> 1 1, 1, d=,>

    1 1 1 0, 0, d=1,> 1, 1, d=2,> 1 1, 1, d=,>

    T"e 24 noncanonical &attern% of t"e for# 01/11/111/, 10/11/111/, or 11/11/111/ ="ere an /P denote%don`t careP> are not generated in t"e re%)lt of a co#&)tational o&eration. oe+er, a% li%ted in Table 5, t"e%e24 bit &attern% do #a& to +al)e% in t"e range 0. T"e bit &attern in a a %ignificand can affect "o t"ea i% &ro&agated =%ee B.2>.

    !age 22 o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    23/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    "6 on-interchange format$ "6"0

    @i-e interc"ange for#at%, noninterc"ange for#at% are c"aracteriHed b' t"e &ara#eter% b,p, e+a=, and e+in,and &ro+ide all t"e re&re%entation% of floating&oint data defined in ter#% of t"o%e &ara#eter% in5.2 and5..?nli-e interc"ange for#at%, bit %tring encoding% of noninterc"ange for#at% are not %&ecified b' t"i% %tandard.T"eir encoding% %"o)ld be defined %o t"at all #e#ber% )%e t"e %a#e a#o)nt of %torage.

    T"i% %tandard doe% not re()ire an i#&le#entation to &ro+ide an' noninterc"ange for#at, b)t ani#&le#entation t"at doe% not %)&&ort t"e ide%t ba%ic for#at %"o)ld %)&&ort an e=ten(e( noninterc"angefor#at t"at e/tend% t"e ide%t ba%ic for#at t"at i% %)&&orted.

    Table $ %&ecifie% t"e #ini#)# &reci%ion and e/&onent range of %)c" e/tended for#at%:

    Table 7/tended format #arameter$ for floating-#oint n+mber$0

    ?xtended formats associated ,ith:

    @arameter !inary32 !inary# decimal#

    pdigits ] 2 64 20

    emax] 102 16B 6144

    emin 1022 N16B2 614

    +ote3t"e #ini#)# e/&onent range i% t"at of t"e ne/t ider ba%ic for#at, "ile t"e #ini#)# &reci%ion i%inter#ediate beteen t"e ide%t %)&&orted ba%ic for#at and t"e ne/t ider ba%ic for#at.

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 2T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    24/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    6" ode$ and ro+nding 6"0

    6"! ode $#ecification6"!"0

    A #ode i% an i#&licit &ara#eter to o&eration% of t"i% %tandard. All i#&le#entation% %"all &ro+ide t"ero)nding direction #ode% =%ee 6.2> and %"o)ld &ro+ide alternate e/ce&tion "andling #ode% =%eeAnne/ >.

    it" con%tant#ode %&ecification, a )%er #a' %&ecif' a con%tant +al)e for a #ode &ara#eter. it" d'na#ic#ode %&ecification, a )%er #a' %&ecif' t"at t"e #ode &ara#eter a%%)#e% t"e +al)e of a d'na#ic #ode+ariable. Mode% in t"i% %tandard #a' be %)&&orted it" con%tant#ode %&ecification or d'na#ic#ode%&ecification, or bot", a% defined b' t"e lang)age. Mode %&ecification i% intended to be b' #ean% oftran%lation directi+e%, %)c" a% &rag#a%.

    For con%tant#ode %&ecification, t"e i#&le#entation &ro+ide% lang)agedefined #ean% to %&ecif' a con%tant+al)e for t"e #ode &ara#eter for all %tandard o&eration% in a lang)agedefined %'ntactic )nit of t"e &rogra#."et"er and "o e/ternal f)nction call% are affected b' a con%tant#ode %&ecification for t"eir i##ediatel'containing %tatic %co&e i% lang)age defined.

    For d'na#ic#ode %&ecification, t"e i#&le#entation &ro+ide% lang)agedefined #ean% to %&ecif' t"at t"e#ode &ara#eter a%%)#e% t"e +al)e of a d'na#ic #ode +ariable for all %tandard o&eration% in a lang)agedefined %'ntactic )nit of t"e &rogra#. T"e i#&le#entation initialiHe% a d'na#ic #ode +ariable to t"e defa)lt+al)e for t"e #ode. it"in it% lang)agedefined =d'na#ic> %co&e, c"ange% to t"e +al)e of a d'na#ic #ode

    +ariable are )nder t"e control of t"e )%er +ia t"e o&eration% in $.$.6 and$.$.$.

    n t"e ab%ence of an' e/&licit %&ecification in t"e &rogra#, it i% lang)agedefined "et"er t"e #ode &ara#etera%%)#e% t"e defa)lt #ode +al)e or t"e +al)e of a d'na#ic #ode +ariable.

    T"e folloing a%&ect% of d'na#ic #ode +ariable% are lang)age =or i#&le#entation> defined:

    L t"e effect of c"anging t"e +al)e of t"e #ode +ariable in an a%'nc"rono)% e+ent, %)c" a% in anot"ert"read or %ignal "andler,

    L "et"er t"e +al)e of t"e #ode +ariable can be deter#ined b' non&rogra##atic #ean%, %)c" a% adeb)gger.

    6"2 Ro+nding direction mode$ 6"2"0

    Ro)nding ta-e% a n)#ber regarded a% infinitel' &reci%e and, if nece%%ar', #odifie% it to fit in t"e de%tination%for#at "ile &er"a&% %ignaling t"e ine/act e/ce&tion =%ee .6>, )nderflo, or o+erflo. +er' o&eration %"allbe &erfor#ed a% if it fir%t &rod)ced an inter#ediate re%)lt correct to infinite &reci%ion and it" )nbo)ndedrange, and t"en ro)nded t"at re%)lt according to one of t"e #ode% in t"i% cla)%e.

    T"e ro)nding direction #ode affect% all co#&)tational o&eration% t"at #ig"t be ine/act. onHero n)#ericfloating&oint re%)lt% ala'% "a+e t"e %a#e %ign a% t"e )nro)nded re%)lt.

    T"e ro)nding direction #ode #a' affect t"e %ign% of Hero %)#% =%ee B.>, and doe% affect t"e t"re%"old%be'ond "ic" o+erflo =%ee.4> and )nderflo =%ee.5> are %ignaled.

    #&le#entation% %)&&orting bot" deci#al and binar' for#at% %"all &ro+ide %e&arate ro)nding direction #ode%for binar' and deci#al. O&eration% ret)rning re%)lt% in internal floating&oint for#at )%e t"e ro)ndingdirection #ode a%%ociated it" t"e radi/ of t"e re%)lt%. O&eration% con+erting fro# an o&erand in internalfloating&oint for#at to a re%)lt in integer for#at or e/ternal c"aracter %e()ence for#at )%e t"e ro)ndingdirection #ode a%%ociated it" t"e radi/ of t"e o&erand.

    !age 24 o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    25/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    6"2"! Ro+nding direction mode$ to neare$t6"2 " ! " 0

    n t"e%e #ode% an infinitel' &reci%e re%)lt it" #agnit)de at lea%t be+a= =bNb1p> %"all ro)nd to Y it" noc"ange in %ignQ "ere e+a=andpare deter#ined b' t"e de%tination for#at =%ee la)%e5.0>. it":

    L ro)ndTie%To+en, the floating-point number nearest to the infinitely precise result shall be

    delivered; if the two nearest floating-point numbers bracketing an unrepresentable infinitely

    precise result are equally near, the one with an even least significant digit shall be delivered.An implementation of this standard shall provide roundTie%To+en. t %"all be t"e defa)lt ro)ndingdirection #ode for re%)lt% in binar' for#at%. T"e defa)lt ro)nding direction #ode for re%)lt% indeci#al for#at% i% lang)agedefined, b)t %"o)ld be ro)ndTie%To+en.

    L ro)ndTie%ToAa', the floating-point number nearest to the infinitely precise result shall bedelivered; if the two nearest floating-point numbers bracketing an unrepresentable infinitelyprecise result are equally near, the one with larger magnitude shall be delivered.

    A decimal implementation of this standard shall provide roundTiesToAway as a user-selectablerounding direction mode.

    6"2"2 Directed ro+nding mode$6"2"2"0

    An i#&le#entation %"all al%o &ro+ide t"ree ot"er )%er%electable ro)nding direction #ode%, t"e directedro)nding #ode% ro)ndToard!o%iti+e, ro)ndToardegati+e, and ro)ndToardJero. it":

    L ro)ndToard!o%iti+e, t"e re%)lt %"all be t"e for#at% floating&oint n)#ber =&o%%ibl' Y> clo%e%t toand no le%% t"an t"e infinitel' &reci%e re%)lt.

    L ro)ndToardegati+e, t"e re%)lt %"all be t"e for#at% floating&oint n)#ber =&o%%ibl' NY> clo%e%t toand no greater t"an t"e infinitel' &reci%e re%)lt.

    L ro)ndToardJero, t"e re%)lt %"all be t"e for#at% floating&oint n)#ber clo%e%t to and no greater in#agnit)de t"an t"e infinitel' &reci%e re%)lt.

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 25T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    26/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    7" O#eration$ 7"0

    7"! Oerie(7"!"0

    All confor#ing i#&le#entation% of t"i% %tandard %"all &ro+ide t"e o&eration% li%ted in t"i% cla)%e. ac" of t"eco#&)tational o&eration% %&ecified b' t"i% %tandard %"all be &erfor#ed a% if it fir%t &rod)ced an inter#ediate

    re%)lt correct to infinite &reci%ion and it" )nbo)nded range, and t"en coerced t"i% inter#ediate re%)lt to fit int"e de%tination% for#at =%ee la)%e 6 and la)%e>. la)%e Ba)g#ent% t"e folloing %&ecification% to co+er_0, _Y, and aQ la)%e en)#erate% e/ce&tion% ca)%ed b' e/ce&tional o&erand% and e/ce&tional re%)lt%.

    n t"i% %tandard, o&eration% are ritten a% na#ed f)nction%Q in a %&ecific &rogra##ing en+iron#ent t"e' #ig"tbe re&re%ented b' o&erator%, or b' fa#ilie% of for#at%&ecific f)nction%, or b' generic f)nction% "o%e na#e%#a' differ fro# t"o%e in t"i% %tandard.

    O&eration% are broadl' cla%%ified in fo)r gro)&% according to t"e t'&e% of re%)lt% and e/ce&tion% t"e' &rod)ce:

    L generalco#&)tational o&eration% &rod)ce floating&oint re%)lt%, ro)nd all re%)lt% according tola)%e 6, and #ig"t %ignal t"e floating&oint e/ce&tion% of la)%e,

    L ()ietco#&)tational o&eration% &rod)ce floating&oint re%)lt% and do not %ignal floating&ointe/ce&tion%,

    L %ignalingco#&)tational o&eration% &rod)ce no floating&oint re%)lt% and #ig"t %ignal floating&oint

    e/ce&tion%Q co#&ari%on% are %ignalingco#&)tational o&eration%

    L nonco#&)tational o&eration% do not &rod)ce floating&oint re%)lt% and do not %ignal floating&ointe/ce&tion%.

    O&eration% in t"e fir%t t"ree gro)&% are referred to collecti+el' a% co#&)tational o&eration%.P

    O&eration% are al%o cla%%ified in to a'% according to t"e relation%"i& beteen t"e re%)lt for#at and t"eo&erand for#at%:

    L "o#ogeneo)% o&eration%, in "ic" t"e floating&oint o&erand% and floating&oint re%)lt are all of t"e%a#e for#at,

    L or+at.o&eration%, "ic" indicate t"e for#at of t"e re%)lt, inde&endent of t"e for#at of t"eo&erand%.

    @ang)age% #ig"t &er#it ot"er -ind% of o&eration% and co#bination% of o&eration% into e/&re%%ion%. ' t"eir

    e/&re%%ion e+al)ation r)le%, lang)age% %&ecif' "en and "o %)c" o&eration% and e/&re%%ion% are #a&&edinto t"e o&eration% of t"i% %tandard.

    n t"e o&eration de%cri&tion% t"at follo, o&erand for#at% are indicated b'

    D 'our*eto re&re%ent "o#ogeneo)% floating&oint o&erand for#at%.

    D 'our*e1, 'our*e2, 'our*eto re&re%ent non"o#ogeneo)% floating&oint o&erand for#at%.

    D int to re&re%ent integer o&erand for#at%.

    or+at.indicate% t"at t"e na#e of t"e o&eration %&ecifie% t"e floating&oint de%tinationor+at, "ic" #ig"tbe different fro# t"e floating&oint o&erand% for#at. T"ere are or+at.+er%ion% of t"e%e o&eration% fore+er' %)&&orted non%torage floating&oint for#at.

    intFor+at.indicate% t"at t"e na#e of t"e o&eration %&ecifie% t"e integer de%tination for#at.

    n t"e o&eration de%cri&tion% t"at follo, lang)age% define "ic" of t"eir t'&e% corre%&ond to o&erand% andre%)lt% called int, intFor+at., *hara*ter%e>uen*e,or *onver'ion%pe*ii*ation . @ang)age% it" bot" %ignedand )n%igned integer t'&e% %"o)ld %)&&ort bot" %igned and )n%igned int and intFor+at. o&erand% andre%)lt%.

    7"2 Decimal e#onent calc+lation7"2"0

    A% di%c)%%ed in 5., a floating&oint n)#ber #a' "a+e #)lti&le re&re%entation% in a deci#al for#at.T"erefore, deci#al arit"#etic in+ol+e% not onl' co#&)ting t"e &ro&er n)#erical re%)lt b)t al%o %electing t"e&ro&er #e#ber of t"at floating&oint n)#ber`% co"ort.

    !age 26 o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    27/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    Except for the quantize operation, the valueof a floating-point result (and hence its cohort) is determinedby the operation and the operands' values; it is never dependent on the representation orencoding of anoperand.

    T"e %election of a &artic)lar re&re%entation for a floating&oint re%)lt i% de&endent on t"e o&erand%re&re%entation%, a% de%cribed belo, b)t i% not affected b' t"eir encoding.

    For certain co#&)tational o&eration%, if t"e re%)lt i% ine/act, t"e co"ort #e#ber of lea%t &o%%ible e/&onent i%)%ed to get t"e longe%t &o%%ible %ignificandQ if t"e re%)lt i% e/act, t"e co"ort #e#ber i% %elected ba%ed on t"e&referred e/&onent for a re%)lt of t"at o&eration, a f)nction of t"e e/&onent% of t"e in&)t%.

    For ot"er co#&)tational o&eration%, "et"er or not t"e re%)lt i% e/act, t"e co"ort #e#ber i% %elected ba%ed ont"e &referred e/&onent for a re%)lt of t"at o&eration. T")% for finite=, de&ending on t"e re&re%entation ofHero, 0=#ig"t re%)lt in a different #e#ber of=`% co"ort.f t"e re%)lt`% co"ort doe% not incl)de a #e#ber it" t"e &referred e/&onent, t"e #e#ber it" t"e e/&onentclo%e%t to t"e &referred e/&onent i% )%ed.

    n t"e de%cri&tion% t"at follo, ==> i% t"e e/&onent >of t"e re&re%entation of a finite floating&oint n)#ber=)f=i% infinite, ==> i% Y.

    7". 8omogeneo+$ general-com#+tational o#eration$7"."0

    7"."! eneral o#eration$7"."!"0

    #&le#entation% %"all &ro+ide t"e folloing "o#ogeneo)% generalco#&)tational o&eration% for all %)&&ortednon%torage floating&oint for#at%Q t"e' ne+er &ro&agate noncanonical re%)lt%. T"eir de%tination for#at i%indicated a%'our*eFor+at:

    L 'our*eFor+atround0oIntegral0ies0o?en='our*e>'our*eFor+atround0oIntegral0ies0oA,ay='our*e>'our*eFor+atround0oIntegral0o,ardero='our*e>'our*eFor+atround0oIntegral0o,ard@ositie='our*e>'our*eFor+atround0oIntegral0o,ard+egatie='our*e>See$.. T"e &referred e/&onent i% #a/===>, 0>.

    L 'our*eFor+atround0oIntegral?xact='our*e>See$.. T"e &referred e/&onent i% #a/===>, 0>.

    L 'our*eFor+at nextBp='our*e>'our*eFor+at nextDo,n='our*e>

    nextBp==> i% t"e lea%t floating&oint n)#ber in t"e for#at of=t"at co#&are% greater t"an=)f=i%t"e negati+e n)#ber of lea%t #agnit)de in=% for#at, nextBp==> i% N0. nextBp=_0> i% t"e &o%iti+en)#ber of lea%t #agnit)de in=% for#at. nextBp=Y> i% Y, and nextBp=NY> i% t"e finite negati+en)#ber large%t in #agnit)de. "en=i% a, t"en t"e re%)lt i% according to B.2.

    T"e &referred e/&onent i% t"e lea%t &o%%ible.

    nextDo,n==> i% ne/t?&==>.

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 2$T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    28/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    D 'our*eFor+at nextAfter='our*e, 'our*e>

    nextAfter(x,y) is the next floating-point number that neighborsxin the direction towardy, in theformat ofx:

    D f eit"er=ory i% a, t"en t"e re%)lt i% according to B.2.

    D f=y, t"en nextAfter==,y> i% co&'Sign==,y>.D f =Gy, t"en nextAfter==,y> i% ne/t?&==>Q if =Hy, t"en nextAfter==,y> i% ne/tDon==>)

    O+erflo i% %ignaled "en=i% finite b)t nextAfter==,y> i% infiniteQ )nderflo i% %ignaled "ennextAfter==,y> lie% %trictl' beteen _be+inQ in bot" ca%e%, ine/act i% %ignaled.

    T"e &referred e/&onent i% ==>.

    L 'our*eFor+atremainder='our*e, 'our*e>

    "eny0 , t"e re#ainder rremainder==,y>i% defined regardle%% of t"e ro)nding direction #odeb' t"e #at"e#atical relation r=NyUn , "ere n i% t"e integer neare%t t"e e/act n)#ber =7yQ"ene+er nN=7y , t"en ni% e+en. T")%, t"e re#ainder i% ala'% e/act. f r0 , it% %ign %"all bet"at of=.

    T"e &referred e/&onent i% #in===>, =y>>.

    D 'our*eFor+atmin+um='our*e, 'our*e>'our*eFor+atmax+um='our*e, 'our*e>'our*eFor+atmin+um*ag='our*e, 'our*e>'our*eFor+atmax+um*ag='our*e, 'our*e>

    min+um==,y> i% t"e canonical floating&oint n)#ber=if =\y,yif y\=, t"e canonicaliHed floating&oint n)#ber if one o&erand i% a floating&oint n)#ber and t"e ot"er a a. Ot"eri%e it i% eit"er=ory.

    max+um==,y> i% t"e canonical floating&oint n)#beryif =\y,=if y\=, t"e canonicaliHed floating&oint n)#ber if one o&erand i% a floating&oint n)#ber and t"e ot"er a a. Ot"eri%e it i% eit"er=ory.

    min+um*ag==,y> i%=if =\y,yif y\=, ot"eri%e #in)#==,y>.max+um*ag==,y> i%=if =y,yif y=, otherwise maxNum(x,y).T"e &referred e/&onent i% ==> if=i% t"e re%)lt, =y> ifyi% t"e re%)lt.

    7"."2 Decimal o#eration7"."2"0

    #&le#entation% %)&&orting deci#al for#at% %"all &ro+ide t"e folloing "o#ogeneo)% generalco#&)tationalo&eration for all %)&&orted non%torage deci#al floating&oint for#at%. t ne+er &ro&agate% noncanonicalre%)lt%. T"e de%tination for#at i% indicated a%'our*eFor+at:

    D 'our*eFor+at)uanti(e='our*e, 'our*e>

    For finite deci#al o&erand%=andy of t"e %a#e for#at, )uanti(e==,y> i% a floating&oint n)#ber int"e %a#e for#at "ic" "a% t"e %a#e n)#erical +al)e a% =and t"e %a#e ()ant)# a%y)f t"e e/&onent

    i% being increa%ed, ro)nding according to t"e &re+ailing ro)nding direction #ode #ig"t occ)r: t"ere%)lt i% a different floating&oint re&re%entation and ine/act i% %ignaled if t"e re%)lt doe% not "a+e t"e%a#e n)#erical +al)e a%=. f t"e e/&onent i% being decrea%ed and t"e %ignificand of t"e re%)lt o)ld"a+e #ore t"anpdigit%, in+alid i% %ignaled and t"e re%)lt i% a. f one or bot" o&erand% are at"e r)le% inB.2 are folloed. Ot"eri%e if onl' one o&erand i% infinite t"en in+alid i% %ignaled and t"ere%)lt i% a. f bot" o&erand% are infinite t"en t"e re%)lt i% canonical Y it" t"e %ign of =. ()antiHedoe% not %ignal )nderflo or o+erflo.

    The preferred exponent is Q(y).

    !age 2B o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    29/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    7".". logBFormato#eration$7" . " . " 0

    #&le#entation% %"all &ro+ide t"e folloing generalco#&)tational o&eration% for all %)&&orted non%toragefloating&oint for#at%. For eac" %)&&orted non%torage floating&oint for#at, lang)age% define an a%%ociated&og3For+atto contain t"e integral +al)e% of log==>. T"e &og3For+at #ig"t be a floating&oint for#at or aninteger for#at. T"e &og3For+at%"all incl)de all integer% beteen _2U=e+a= p> incl)%i+e, "ic" incl)de%t"e %cale factor% for %caling beteen t"e finite n)#ber% of large%t and %#alle%t #agnit)de, a% ell a% %cale

    factor% &rod)ced b' %caled&rod)ct o&eration% =%ee Anne/ F>.

    f &og3For+ati% a floating&oint for#at, t"en t"e folloing o&eration% are "o#ogeneo)%. f &og3For+ati% aninteger for#at, t"en t"e fir%t o&erand and t"e floating&oint re%)lt of %cale are of t"e %a#e for#at.

    D &og3For+atlogor+at.su!traction='our*e1, 'our*e2>or+at.multiplication='our*e1, 'our*e2>or+at.diision='our*e1, 'our*e2>

    For inexact decimal results, the preferred exponent is the least possible. For exact decimal results,the preferred exponent is min(Q(x), Q(y)) for addition and subtraction, Q(x) + Q(y) formultiplication, and Q(x) Q(y) for the division x/y.

    D or+at.s)uareoot='our*e>The squareRoot operation is defined and has a positive sign for all operands ]0, except that

    squareRoot(0) shall be 0.

    For inexact decimal results, the preferred exponent is the least possible. For exact decimal results,

    the preferred exponent is floor(Q(x)/2).D or+at.fused*ultiplyAdd='our*e1, 'our*e2, 'our*e>

    T"e o&eration fused*ultiplyAdd==,y,4> co#&)te% ==Uy>4a% if it" )nbo)nded range and &reci%ion,ro)nding onl' once to t"e de%tination for#at. o )nderflo, o+erflo, or ine/act e/ce&tion =la)%e

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 2T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    30/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    > can ari%e d)e to t"e #)lti&lication, b)t onl' d)e to t"e additionQ and %o f)%edM)lti&l'Add differ%fro# a #)lti&lication o&eration folloed b' an addition o&eration.

    For ine/act deci#al re%)lt%, t"e &referred e/&onent i% t"e lea%t &o%%ible. For e/act deci#al re%)lt%,t"e &referred e/&onent i% #in===>=y>, =H>>.

    D or+at.conert9int>

    t %"all be &o%%ible to con+ert fro# all %)&&orted %igned and )n%igned integer for#at% to all%)&&orted non%torage floating&oint for#at%. ntegral +al)e% are con+erted e/actl' fro# integerfor#at% to floating&oint for#at% "ene+er t"e +al)e i% re&re%entable in bot" for#at%. f t"econ+erted +al)e i% not e/actl' re&re%entable in t"e de%tination for#at, t"e defa)lt re%)lt i% deter#inedaccording to t"e &re+ailing ro)nding direction #ode, and an ine/act or floating&oint o+erfloe/ce&tion ari%e% a% %&ecified in la)%e ,*)%t a% it" arit"#etic o&eration%.

    T"e &referred e/&onent i% 0.

    #&le#entation% %"all &ro+ide t"e folloing intFor+at.generalco#&)tational o&eration% for de%tination%of all %)&&orted integer for#at% and for o&erand% of all %)&&orted non%torage floating&oint for#at%.

    D intFor+at.conert0oInteger0ies0o?en='our*e>intFor+at.conert0oInteger0o,ardero='our*e>intFor+at.conert0oInteger0o,ard@ositie='our*e>

    intFor+at.conert0oInteger0o,ard+egatie='our*e>intFor+at.conert0oInteger0ies0oA,ay='our*e>See$.Bfor detail%.

    D intFor+at.conert0oInteger?xact0ies0o?en='our*e>intFor+at.conert0oInteger?xact0o,ardero='our*e>intFor+at.conert0oInteger?xact0o,ard@ositie='our*e>intFor+at.conert0oInteger?xact0o,ard+egatie='our*e>intFor+at.conert0oInteger?xact0ies0oA,ay='our*e>See$.Bfor detail%.

    7"4"2 )oner$ion o#eration$ for all format$7"4"2"0

    #&le#entation% %"all &ro+ide t"e folloing or+at. con+er%ion o&eration% fro# all %)&&orted floating&oint for#at% to all %)&&orted floating&oint for#at%, incl)ding %torage for#at%. So#e for#at con+er%iono&eration% &rod)ce re%)lt% in a different radi/ t"an t"e o&erand%.

    D or+at.conert='our*e>

    f t"e con+er%ion i% to a for#at in a different radi/ or to a narroer &reci%ion in t"e %a#e radi/, t"ere%)lt %"all be ro)nded a% %&ecified in la)%e 6.on+er%ion to a for#at it" t"e %a#e radi/ b)tider &reci%ion and range i% ala'% e/act.

    For ine/act con+er%ion% fro# binar' to deci#al for#at%, t"e &referred e/&onent i% t"e lea%t &o%%ible.For e/act con+er%ion% fro# binar' to deci#al for#at%, t"e &referred e/&onent i% t"e #a/i#)#&o%%ible.

    For con+er%ion% beteen internal deci#al for#at%, t"e &referred e/&onent i% ='our*e>.

    D or+at.conert=romDecimalCharacter=(e*i+a&Chara*ter%e>uen*e >See$.12.. T"e &referred e/&onent i% =(e*i+a&Chara*ter%e>uen*e >.

    D (e*i+a&Chara*ter%e>uen*econert0oDecimalCharacter='our*e, *onver'ion%pe*ii*ation>See$.12.. T"e *onver'ion%pe*ii*ation %&ecifie% t"e &reci%ion and for#atting of t"e(e*i+a&Chara*ter%e>uen*e re%)lt.

    7"4". )oner$ion o#eration$ for binar' format$7"4"."0

    #&le#entation% %"all &ro+ide t"e folloingor+at. con+er%ion o&eration% to and fro# all %)&&orted binar'floating&oint for#at%, incl)ding %torage for#at%.

    !age 0 o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    31/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    D or+at.conert=romexCharacter=he=Chara*ter%e>uen*e >See$.12.2.

    D he=Chara*ter%e>uen*econert0oexCharacter='our*e, *onver'ion%pe*ii*ation>See$.12.2. T"e *onver'ion%pe*ii*ation %&ecifie% t"e &reci%ion and for#atting of t"ehe=Chara*ter%e>uen*e re%)lt.

    7" 8omogeneo+$ 9+iet-com#+tational o#eration$7""0

    7""! Sign o#eration$7""!"0

    #&le#entation% %"all &ro+ide t"e folloing "o#ogeneo)% ()ietco#&)tational %ign o&eration% for all%)&&orted non%torage floating&oint for#at%. T"e' #ig"t &ro&agate noncanonical encoding%. T"e' are&erfor#ed a% if on %tring% of bit%, treating floating&oint n)#ber% and a% ali-e, and "ence %ignal noe/ce&tion.

    D 'our*eFor+atcopy='our*e>'our*eFor+atnegate='our*e>'our*eFor+ata!s='our*e>

    copy==>co&ie% a floating&oint o&erand=to a de%tination in t"e %a#e for#at, it" no c"ange.

    negate==> co&ie% a floating&oint o&erand=to a de%tination in t"e %a#e for#at, re+er%ing t"e %ign.

    0?= i% not t"e %a#e a%?= ornegate==>.a!s==>co&ie% a floating&oint o&erand=to a de%tination in t"e %a#e for#at, c"anging t"e %ign to&o%iti+e.

    T"e &referred e/&onent i% ==>.

    D 'our*eFor+atcopyEign='our*e, 'our*e>

    copyEign==, yJ co&ie% a floating&oint o&erand=to a de%tination in t"e %a#e for#at a%=, b)t it" t"e%ign ofy.

    T"e &referred e/&onent i% ==>.

    7""2 Decimal re-encoding o#eration$

    For eac" %)&&orted deci#al for#at =if an'>, t"e i#&le#entation %"all &ro+ide t"e folloing o&eration% tocon+ert beteen t"e internal deci#al for#at and t"e to %tandard encoding% for t"at for#at. T"e%e o&eration%enable &ortable &rogra#% t"at are inde&endent of t"e i#&le#entation% encoding for deci#al t'&e% to acce%%data re&re%ented it" eit"er %tandard encoding.

    D (e*i+a&En*o(ingTypeencodeDecimal=(e*i+a&Type>:encode% t"e +al)e of t"e o&erand )%ing deci#al encoding

    D (e*i+a&TypedecodeDecimal=(e*i+a&En*o(ingType >:decode% t"e deci#alencoded o&erand

    D binaryEn*o(ingTypeencode:encode% t"e +al)e of t"e o&erand )%ing t"e binar' encoding

    D (e*i+a&Typedecode:

    decode% t"e binar'encoded o&erand

    "ere (e*i+a&En*o(ingType i% a lang)agedefined t'&e for %toring deci#alencoded deci#al floating&ointdata, binaryEn*o(ingType i% a lang)agedefined t'&e for %toring binar'encoded deci#al floating&oint data,and (e*i+a&Typei% t"e t'&e of t"e gi+en deci#al floating&oint for#at.

    o&'rig"t I 2006 . All rig"t% re%er+ed. !age 1T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    32/59

    Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54October 4, 2006

    7"6 Signaling-com#+tational o#eration$7" 6 " 0

    7"6"! )om#ari$on$7"6 " ! " 0

    #&le#entation% %"all &ro+ide t"e folloing co#&ari%on o&eration%, for all %)&&orted non%torage floating&oint o&erand% of t"e %a#e radi/:

    D boo&ean compare?)ual='our*e1,'our*e2>boo&ean compare+ot?)ual='our*e1,'our*e2>boo&ean compareFreater='our*e1,'our*e2>boo&ean compareFreater?)ual='our*e1,'our*e2>boo&ean compareLess='our*e1,'our*e2>boo&ean compareLess?)ual='our*e1,'our*e2>boo&ean compareEignaling+otFreater='our*e1,'our*e2>boo&ean compareEignalingLessBnordered='our*e1,'our*e2>boo&ean compareEignaling+otLess='our*e1,'our*e2>boo&ean compareEignalingFreaterBnordered='our*e1,'our*e2>boo&ean compareGuietFreater='our*e1,'our*e2>boo&ean compareGuietFreater?)ual='our*e1,'our*e2>boo&ean compareGuietLess='our*e1,'our*e2>

    boo&ean compareGuietLess?)ual='our*e1,'our*e2>boo&ean compareBnordered='our*e1,'our*e2>boo&ean compareGuiet+otFreater9'our*e1,'our*e2>boo&ean compareGuietLessBnordered='our*e1,'our*e2>boo&ean compareGuiet+otLess9'our*e1,'our*e2>boo&ean compareGuietFreaterBnordered='our*e1,'our*e2>boo&ean compareHrdered9'our*e1,'our*e2>

    See$.11 for detail%.

    !age 2 o&'rig"t I 2006 . All rig"t% re%er+ed.T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

  • 8/12/2019 F2003 Part 1, Floating Point Arithmetic Standard 2006 Included in 1539-1

    33/59

    DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5October 4, 2006

    7"6"2 /ce#tion $ignaling-com#+tational o#eration$7"6"2"0

    T"i% o&eration %ignal% t"e e/ce&tion% %&ecified b' it% o&erand, in+o-ing eit"er defa)lt or, if e/&licitl're()e%ted, a lang)agedefined alternate "andling:

    D voi( signal?xception=e=*eptionBroupType>:%ignal% t"e e/ce&tion% %&ecified in t"e e=*eptionBroupTypeo&erand, "ic" can re&re%ent an' %)b%etof t"e e/ce&tion%.

    "et"er %ignal/ce&tion additionall' %ignal% t"e ine/act e/ce&tion "ene+er it %ignal% o+erflo or)nderflo i% lang)age defined. f %ignal/ce&tion %ignal% o+erflo and ine/act or )nderflo and ine/act, t"enit %ignal% o+erflo or )nderflo before ine/act. Ot"eri%e, t"e order in "ic" t"e e/ce&tion% are %ignaled i%)n%&ecified.

    7"7 on-com#+tational o#eration$7"7"0

    7"7"! )onformance #redicate$

    #&le#entation% %"all &ro+ide t"e folloing nonco#&)tational o&eration%, tr)e if and onl' if t"e indicatedcondition% are tr)e:

    D boo&ean is$"=voi(>is$"=>i% tr)e if and onl' if t"i% &rogra##ing en+iron#ent confor#% to AS Std $541B5.

    D boo&ean is$"=voi(>

    is$"=> i% tr)e if and onl' if t"i% &rogra##ing en+iron#ent confor#% to t"i% %tandard.

    @ang)age% %"o)ld #a-e t"e%e &redicate% a+ailable at tran%lation ti#e =if a&&licable> in ca%e% "ere t"eir+al)e% can be deter#ined at t"at &oint.

    7"7"2 eneral o#eration$7"7"2"0

    #&le#entation% %"all &ro+ide t"e folloing nonco#&)tational o&eration% for all %)&&orted non%toragefloating&oint for#at%. T"e' are ne+er e/ce&tional, e+en for %ignaling a%.:

    D boo&ean isEigned='our*e>isEigned==> i% tr)e if and onl' if="a% negati+e %ign. isEigneda&&lie% to Hero% and a% a% ell.

    D boo&eanis+ormal='our*e>

    is+ormal==> i% tr)e if and onl' if=i% nor#al =not Hero, %)bnor#al, infinit', or a>.

    D boo&eanis=inite='our*e>

    is=inite==> i% tr)e if and onl' if=i% Hero, %)bnor#al or nor#al =not infinit' or a>.

    D boo&eanisero='our*e>

    isero==> i% tr)e if and onl' if= _0.

    D boo&eanisEu!normal='our*e>

    isEu!normal==> i% tr)e if and onl' if=i% %)bnor#al.

    D boo&eanisInfinity='our*e>

    isInfinity==> i% tr)e if and onl' if=i% infinite.D boo&eanis+a+='our*e>

    is+a+==> i% tr)e if and onl' if=i% a a.

    D boo&eanisEignaling='our*e>

    isEignaling==> i% tr)e if and onl' if=i% a %ignaling a.

    D boo&eanisCanonical='our*e>

    isCanonical==> i% tr)e if and onl' if = i% a finite n)#ber, infinit', or a t"at i% canonical.#&le#entation% %"o)ld e/tend isCanonical==> to noninterc"ange for#at% in a'% a&&ro&riate to

    o&'rig"t I 2006 . All rig"t% re%er+ed. !