Вы находитесь на странице: 1из 59

October 4, 2006

DRAFT Standard for


Floating-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 binary
and decimal floating-point arithmetic in computer programming environments. Exception conditions
are 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 be
realized 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 are
uni#uely determined by the values of the input data! se#uence of operations! and destination
formats! all under user control.
&e'(ord$% computer! floating-point! arithmetic! rounding! format! interchange! number! binary!
decimal! subnormal! $a$! significand! exponent.
Copyright 2006 by the IEEE
Three Park Avenue
New York, New York 10016!""#, $%A
A&& right' re'erve()
Thi' (o*u+ent i' an unapprove( (ra,t o, a propo'e( IEEE %tan(ar() A' 'u*h, thi' (o*u+ent i' 'ub-e*t to *hange) $%E AT
Y.$/ .0N /I%12 3e*au'e thi' i' an unapprove( (ra,t, thi' (o*u+ent +u't not be uti&i4e( ,or any
*on,or+an*e5*o+p&ian*e purpo'e') Per+i''ion i' hereby grante( ,or IEEE %tan(ar(' Co++ittee parti*ipant' to
repro(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 6anager,
%tan(ar(' Inte&&e*tua& Property, IEEE %tan(ar(' A*tivitie' 7epart+ent) .ther entitie' 'eeking per+i''ion to repro(u*e
thi' (o*u+ent, in who&e or in part, +u't obtain per+i''ion ,ro+ the 6anager, %tan(ar(' Inte&&e*tua& Property, IEEE
%tan(ar(' A*tivitie' 7epart+ent)
IEEE %tan(ar(' A*tivitie' 7epart+ent
6anager, %tan(ar(' Inte&&e*tua& Property
88! 9oe' :ane
Pi'*ataway, N; 0<<!8, $%A
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 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 #atter
co+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"ere.it". T"e 0111 %"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 0111 %tandard or for cond)cting
in()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)t
co#&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 0111 #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 0111 Standard% De&art#ent.
)hange hi$tor'
T"e follo.ing table %"o.% t"e c"ange "i%tor' for t"i% doc)#ent.
Version Date Author Description
0.222 3 D4 Original content, &a%%ed fro# Da+id 4o)g" for %t'le%5na#e% c"ange%.
0.22226 0$706706 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%.
0ncl)ded acron'# cla)%e and bibliogra&"' anne/.
:"anged to MS:70111 ;%"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, and 4)
@i#ited font% to Arial, Ti#e% Ae. Ro#an, S'#bol, 5 :o)rier.
1li#inated "i%torical anne/ =e/&ected to be +oted o)t>.
1.0 0$716706 D4 Re%)lt% of %t'le re+ie. 2006 9)l' 16.
1.1 0$712706 D4 Re%)lt% of general #eeting 2006 9)l' 12:
1B Delete 5.6.2 Scaled&rod)ct o&eration, add A.6. Scaled&rod)ct o&eration%
12 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 AaA 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 D4 Re%)lt% of %t'le re+ie. 2006 9)l' 2$.
1.1.6 0B705706 ST: Re%)lt% of %t'le re+ie. 2006 A)g)%t 6.
1.1.4 0B712706 ST: Re%)lt% of general #eeting 2006 A)g)%t 2, and e#ail co##ent%.
1.1.5 0B715706 D4 Re%)lt% of %t'le re+ie. 2006 A)g)%t 15.
1.1.6 0B71$706 D4 Re%)lt% of %t'le re+ie. 2006 A)g)%t 1$.
1.2 02712706 ST: Re%)lt% of %t'le re+ie. 2006 Se&te#ber 12 and general #eeting 2006
Se&te#ber $.
1.2.1 0271$706 ST: Re%)lt% of %t'le re+ie. 2006 Se&te#ber 14.
1.2.6 02726706 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 6.
!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.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
*ntrod+ction
DT"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 For-ing Gro)& of t"e Micro&roce%%or Standard%
S)bco##ittee of t"e Standard% :o##ittee of t"e 0111 :o#&)ter Societ'. T"i% .or- .a% %&on%ored b' t"e
Tec"nical :o##ittee on Micro&roce%%or% and Minico#&)ter%.
!?R!OS1: 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 "ard.are, %oft.are, or a co#bination of t"e t.o. For
o&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 )%er
control.
T"i% %tandard define% a fa#il' of co##erciall' fea%ible .a'% for %'%te#% to &erfor# binar' and deci#al
floating&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> 1n"ance t"e ca&abilitie% and %afet' a+ailable to )%er% and &rogra##er% ."o, t"o)g" not e/&ert in
n)#erical #et"od%, #a' .ell be atte#&ting to &rod)ce n)#ericall' %o&"i%ticated &rogra#%.
4o.e+er, .e recogniHe t"at )tilit' and %afet' are %o#eti#e% antagoni%t%.
c> 1nco)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'. F"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> 1/ec)tionti#e diagno%i% of ano#alie%
2> S#oot"er "andling of e/ce&tion%
6> 0nter+al arit"#etic at a rea%onable co%t
e> !ro+ide for de+elo&#ent of
1> Standard ele#entar' f)nction% %)c" a% e/& and co%
2> 8er' "ig" &reci%ion =#)lti.ord> arit"#etic
6> :o)&ling of n)#erical and %'#bolic algebraic co#&)tation
f> 1nable rat"er t"an &recl)de f)rt"er refine#ent% and e/ten%ion%.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 6
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
Partici#ant$
At t"e ti#e t"i% %tandard .a% co#&leted, t"e .or-ing gro)& "ad t"e follo.ing #e#ber%"i&:
Dan J)ra%, :"air
Ai-en, Ale/
A&&legate, Matt"e.
,aile', 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)%
:o.li%"a., Mi-e
:ra.ford, 9o"n
Darc', 9o%e&" D
Da% Sar#a, Deb*it
Da)#a%, Marc
Da+i%, ,ob
Da+i%, Mar-
Del&, Dic-
De##el, 9i#
1rle, Mar-
Fa"#', 4o%%a#
Fa%ano, 9.!.
Fate#an, Ric"ard
Feng, 1ric
Ferg)%on, Farren
FitFlorea, Ale/
Fo)rnier, @a)rent
Freitag, :"i&
Godard, 0+an
Golli+er, Roger
G)%taf%on, Da+id
4ac-, Mic"el
4arri%on, 9o"n
4a)%er, 9o"n
4ida, CoHo
4ind%, :"ri%
4oare, Gra'don
4o)g", Da+id
4)c-, 9err'
4)ll, 9i#
0ngra%%ia, Mic"ael
9a#e%, Da+id
9a#e%, Ric-
Ka"an, Fillia#
Ka&ernic-, 9o"n
Kar&in%-i, Ric"ard
Kidder, 9eff
Koe+, !la#en
@i, Ren:ang
@i), J"i%")n Ale/
Ma-, Ra'#ond
Mar-%tein, !eter
Mat)la, Da+id
Mel()iond, G)illa)#e
Mori, Aob)'o%"i
Morin, Ricardo
Aedial-o+, Aed
Ael%on, :raig
Ober#an, St)art
O-ada, 9on
Oll#ann, 0an
!ar-%, Mic"ael
!itt#an, To#
!o%t&i%c"il, 1ric
Ried', 9a%on
Sc".arH, 1ric
Scott, Da+id
SenHig, Don
S"ara&o+, 0l'a
S"earer, 9i#
Si), Mic"ael
S#it", Ron
Ste+en%, :")c-
Tang, !eter
Ta'lor, !a#ela
T"o#a%, 9i#
T"o#&%on, ,randon
T"ra%", Fend'
Toda, Aeil
Trong, Son Dao
T%ai, @eonard
T%en, :"arle%
T'de#an, Fred
Fang, @iang Kai
Fe%tbroo-, Scott
Fin-ler, Ste+e
Food, Ant"on'
Calcinal&, ?#it
Je#-e, Fred
Ji##er#ann, !a)l
J)ra%, Dan
!age 4 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
T"e follo.ing #e#ber% of t"e balloting co##ittee +oted on t"i% %tandard. ,alloter% #a' "a+e +oted for
a&&ro+al, di%a&&ro+al, or ab%tention.
To ,e S)&&lied ,' 0111 1tc. 1tc.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 5
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
Table of content$
Table of content$
1. O+er+ie. ......................................................................................................................................................2
1.1 Sco&e....................................................................................................................................................2
1.2 0ncl)%ion%.............................................................................................................................................2
1.6 1/cl)%ion%............................................................................................................................................2
1.4 !)r&o%e.................................................................................................................................................2
1.5 @ang)agedefined7i#&le#entationdefined .........................................................................................2
1.6 Anne/e% .............................................................................................................................................10
2. Reference% ..................................................................................................................................................11
6. Ter#% and definition% .................................................................................................................................12
6.1 :onfor#ance le+el% ...........................................................................................................................12
6.2 Glo%%ar' of ter#% ...............................................................................................................................12
4. Abbre+iation% and acron'#%........................................................................................................................15
5. For#at% .......................................................................................................................................................16
5.1 O+er+ie.: for#at% and confor#ance .................................................................................................16
5.2 S&ecification le+el% ............................................................................................................................1$
5.6 Set% of floating&oint data ..................................................................................................................1$
5.4 ,inar' interc"ange for#at encoding% .................................................................................................12
5.5 Deci#al interc"ange for#at encoding% ..............................................................................................20
5.6 Aoninterc"ange for#at% ...................................................................................................................26
6. Mode% and ro)nding ...................................................................................................................................24
6.1 Mode %&ecification ............................................................................................................................24
6.2 Ro)nding direction #ode% .................................................................................................................24
6.2.1 Ro)nding direction #ode% to neare%t .......................................................................................25
6.2.2 Directed ro)nding #ode% .........................................................................................................25
$. O&eration% ..................................................................................................................................................26
$.1 O+er+ie. ...........................................................................................................................................26
$.2 Deci#al e/&onent calc)lation ............................................................................................................26
$.6 4o#ogeneo)% generalco#&)tational o&eration% ...............................................................................2$
$.6.1 General o&eration% ...................................................................................................................2$
$.6.2 Deci#al o&eration ...................................................................................................................2B
$.6.6 log,For#at o&eration% ............................................................................................................22
$.4 for#atOf generalco#&)tational o&eration% ......................................................................................22
$.4.1 Arit"#etic o&eration% ..............................................................................................................22
$.4.2 :on+er%ion o&eration% for all for#at% ......................................................................................60
$.4.6 :on+er%ion o&eration% for binar' for#at% ...............................................................................60
$.5 4o#ogeneo)% ()ietco#&)tational o&eration%...................................................................................61
$.5.1 Sign o&eration% ........................................................................................................................61
$.5.2 Deci#al reencoding o&eration%...............................................................................................61
$.6 Signalingco#&)tational o&eration% ...................................................................................................62
$.6.1 :o#&ari%on% ............................................................................................................................62
$.6.2 1/ce&tion %ignalingco#&)tational o&eration% ........................................................................66
$.$ Aonco#&)tational o&eration% ...........................................................................................................66
$.$.1 :onfor#ance &redicate%...........................................................................................................66
$.$.2 General o&eration% ...................................................................................................................66
$.$.6 Deci#al o&eration ...................................................................................................................64
$.$.4 O&eration% on %)b%et% of flag% .................................................................................................64
$.$.5 O&eration% on all flag% .............................................................................................................65
!age 6 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
$.$.6 O&eration% on indi+id)al #ode% ..............................................................................................65
$.$.$ O&eration% on all #ode% .it" d'na#ic %&ecification ...............................................................66
$.B Detail% of con+er%ion% fro# floating&oint to integer for#at% ............................................................66
$.2 Detail% of o&eration% to ro)nd a floating&oint dat)# to integral +al)e ..............................................6$
$.10 Detail% of totalOrder &redicate..........................................................................................................6B
$.11 Detail% of co#&ari%on &redicate% .....................................................................................................6B
$.12 Detail% of con+er%ion bet.een internal floating&oint and e/ternal c"aracter %e()ence% .................40
$.12.1 1/ternal c"aracter %e()ence% re&re%enting Hero%, infinitie%, and AaA% ..................................41
$.12.2 1/ternal "e/adeci#al c"aracter %e()ence% re&re%enting finite n)#ber% ................................41
$.12.6 1/ternal deci#al c"aracter %e()ence% re&re%enting finite n)#ber% ........................................42
B. 0nfinit', AaA%, and %ign bit .........................................................................................................................46
B.1 0nfinit' arit"#etic...............................................................................................................................46
B.2 O&eration% .it" AaA% .......................................................................................................................46
B.2.1 AaA encoding% in binar' for#at% ............................................................................................46
B.2.2 AaA encoding% in deci#al for#at% ..........................................................................................44
B.2.6 AaA &ro&agation .....................................................................................................................44
B.6 T"e %ign bit ........................................................................................................................................44
2. Defa)lt e/ce&tion "andling .........................................................................................................................45
2.1 O+er+ie.: e/ce&tion% and flag% .........................................................................................................45
2.2 0n+alid o&eration ................................................................................................................................46
2.6 Di+i%ion b' Hero ................................................................................................................................46
2.4 O+erflo. ...........................................................................................................................................46
2.5 ?nderflo. ..........................................................................................................................................4$
2.6 0ne/act ...............................................................................................................................................4$
Anne/e%...........................................................................................................................................................4B
Anne/ A =infor#ati+e> ,ibliogra&"'...............................................................................................................4B
Anne/ , =infor#ati+e> 1/&re%%ion e+al)ation ................................................................................................42
,.1 O+er+ie...........................................................................................................................................42
,.2 O&ti#iHation.....................................................................................................................................42
,.6 A%%ign#ent%......................................................................................................................................50
Anne/ : =infor#ati+e> Fidento #et"od% for e/&re%%ion e+al)ation................................................................51
Anne/ D =infor#ati+e> 1le#entar' tran%cendental f)nction%...........................................................................56
Anne/ 1 =infor#ati+e> Alternate e/ce&tion "andling #ode%...........................................................................55
1.1 O+er+ie............................................................................................................................................55
1.2 Aonre%)#able alternate e/ce&tion "andling #ode%..........................................................................55
1.6 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 A)#erical %en%iti+it'........................................................................................................................5B
G.6 A)#erical e/ce&tion%.......................................................................................................................5B
G.4 !rogra##ing error%..........................................................................................................................52
,i$t of fig+re$
Fig)re 5.13,inar' interc"ange floating&oint for#at.....................................................................................12
Fig)re 5.23Deci#al interc"ange floating&oint for#at%.................................................................................20
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age $
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
,i$t of table$
Table 13Relation%"i&% bet.een different %&ecification le+el% for a &artic)lar for#at....................................1$
Table 230nterc"ange for#at &ara#eter% defining floating&oint n)#ber%......................................................1B
Table 63,inar' interc"ange for#at encoding &ara#eter%..............................................................................12
Table 43Deci#al interc"ange for#at encoding &ara#eter%............................................................................21
Table 53Decoding 10bit den%el'&ac-ed deci#al to 6 deci#al digit%...........................................................22
Table 631ncoding 6 deci#al digit% to 10bit den%el'&ac-ed deci#al...........................................................22
Table $31/tended for#at &ara#eter% for floating&oint n)#ber%..................................................................26
Table B3Re()ired )nordered()iet &redicate and negation............................................................................62
Table 23Re()ired )nordered%ignaling &redicate% and negation%...................................................................62
Table 103Re()ired )nordered()iet &redicate% and negation% ......................................................................40
Table 113Deci#al con+er%ion &ara#eter # ."en .ide%t %)&&orted for#at i% ba%ic......................................42
Table :.13Fidento o&eration%......................................................................................................................52
Table D.13StandardiHed tran%cendental f)nction%..........................................................................................54
!age B :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
DRAFT Standard for
Floating-Point Arithmetic P74
!" O-er-ie(
!"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%. 1/ce&tion condition% are defined and defa)lt
"andling of t"e%e condition% i% %&ecified.
0t i% intended t"at an i#&le#entation of a floating&oint %'%te# confor#ing to t"i% %tandard can be realiHed
entirel' in %oft.are, entirel' in "ard.are, or in an' co#bination of %oft.are and "ard.are. 0t i% t"e
en+iron#ent t"e )%er of t"e %'%te# %ee% t"at confor#% or fail% to confor# to t"i% %tandard. 4ard.are
co#&onent% t"at re()ire %oft.are %)&&ort to confor# %"all not be %aid to confor# a&art fro# %)c" %oft.are.
!"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"er
o&eration%.
L :on+er%ion% bet.een integer and floating&oint for#at%.
L :on+er%ion% bet.een different floating&oint for#at%.
L :on+er%ion% bet.een 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% =AaA%>.
!". /0cl+$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 0nter&retation of t"e %ign and %ignificand field% of AaA%.
!"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&endent
of ."et"er t"e &roce%%ing i% done in "ard.are, %oft.are, or a co#bination of t"e t.o. For o&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 )%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)ld
be defined b' a &rogra##ing lang)age definition %)&&orting t"i% %tandard, if a+ailable, and ot"er.i%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% to
i#&le#entation% to define.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 2
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
Language-defined be"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 .ill
be"a+e identicall' .it" re%&ect to %)c" lang)agedefined be"a+ior%. @ang)age% t"at a%&ire to.ard
re&rod)cible re%)lt% on all &latfor#% are e/&ected to %&ecif' #ore be"a+ior% t"an lang)age% t"at a%&ire to.ard
#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%. 0f t"e lang)age can be e/tended b' a f)nction librar' or cla%% or &ac-age to &ro+ide a confor#ing
en+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' be
defined b' a lang)age %tandard.
Implementation-defined be"a+ior i% defined b' a %&ecific i#&le#entation of a %&ecific &rogra##ing
en+iron#ent confor#ing to t"i% %tandard. 0#&le#entation% define be"a+ior% not %&ecified b' t"i% %tandard nor
b' 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##ing
en+iron#ent, rat"er t"an of a lang)age %&ecification.
4o.e+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"at
e+er' confor#ing i#&le#entation of t"at lang)age al%o confor#ed a)to#aticall' to t"i% %tandard.
!"6 Anne0e$
!"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/ 1, Anne/ F and Anne/ G incor&orate t"e .or-ing gro)&M% 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-ing
gro)& "o&e% t"at lang)age de%igner%, %tandard% bodie%, and i#&le#enter% .ill de+elo& and
i#&le#ent %&ecification% t"at a&&lication &rogra##er% can e/&loit.
!age 10 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
2" Reference$
2"0
T"e follo.ing referenced doc)#ent% are indi%&en%able for t"e a&&lication of t"i% %tandard:
AAS070111 Std $54N12B5, 0111 Standard for ,inar' Floating!oint Arit"#etic.
1
0SO701: 2B22, Second edition 12221201, !rogra##ing lang)age%%:
2
1
IEEE publications are available from the Institute of Electrical and Electronics Engineers, 445 Hoes Lane, P.O. Box
1331, Piscataway, NJ 08855-1331, USA.
2
ISO 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 0111. All rig"t% re%er+ed. !age 11
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
." Term$ and definition$
."0
."! )onformance le-el$
."!"0
Se+eral -e'.ord% are )%ed to differentiate bet.een 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 "ard.are or %oft.are in t"e de%ign #odel% a%%)#ed b' t"i%
%&ecification. Ot"er "ard.are and %oft.are de%ign #odel% #a' al%o be i#&le#ented.
3.1.2 may: 0ndicate% a co)r%e of action &er#i%%ible .it"in t"e li#it% of t"e %tandard .it" no i#&lied
&reference =O#a'P #ean% Oi% &er#itted toP>.
3.1.3 shall: 0ndicate% #andator' re()ire#ent% %trictl' to be follo.ed in order to confor# to t"e %tandard and
fro# ."ic" no de+iation i% &er#itted =O%"allP #ean% Oi% re()ired toP>.
3.1. should: 0ndicate% 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 or
t"at =in t"e negati+e for#> a certain co)r%e of action i% de&recated b)t not &ro"ibited =O%"o)ldP #ean% Oi%
reco##ended toP>.
."2 2lo$$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 t.o 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/&onentM%
range nonnegati+e.
3.2.3 !inary floating-point num!er: A floating&oint n)#ber .it" radi/ t.o.
3.2. canonical encoding: T"e &referred encoding of a floating&oint re&re%entation in a for#at. A&&lied to
declet%, %ignificand% of finite n)#ber%, infinitie%, and AaA%, e%&eciall' in deci#al for#at%.
3.2." cohort: 0n 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. R0 and S0 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 a
floating&oint e/ce&tion. :o#&ari%on% are co#&)tational o&eration%.
3.2.$ correct rounding: T"i% %tandardM% #et"od of con+erting an infinitel' &reci%e re%)lt to a floating&oint
n)#ber, a% deter#ined b' t"e &re+ailing ro)nding direction #ode. A floating&oint n)#ber %o obtained i% %aid
to 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#ediate
re%)lt% in %)be/&re%%ion% or arg)#ent% for &roced)re%>. So#e lang)age% &lace t"e re%)lt% of inter#ediate
calc)lation% in de%tination% be'ond t"e )%erM% controlQ nonet"ele%%, t"i% %tandard define% t"e re%)lt of an
o&eration in ter#% of t"at de%tinationM% for#at and t"e o&erand%M +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%onable
a&&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. Aote t"at Oe+ent,P Oe/ce&tion,P and O%ignalP are defined in
di+er%e .a'% in different &rogra##ing en+iron#ent%.
!age 12 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
3.2.13 exponent: T"e co#&onent of a finite floating&oint re&re%entation t"at %ignifie% t"e integer &o.er 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 T > R p N 1 ."ere p i% 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 %)&&orted
ba%ic for#at.
3.2.1" external character se)uence: A re&re%entation of a n)#ber or AaA 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 =AaA> t"at i% re&re%entable in a
floating&oint for#at. 0n t"i% %tandard, a floating&oint dat)# i% not al.a'% 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. A
floating&oint dat)# t"at i% not a AaA. 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 finite
n)#ber, a %igned infinit', or a ()iet or %ignaling AaA. A re&re%entation of a finite n)#ber "a% t"ree
co#&onent%: a %ign, an e/&onent, and a %ignificandQ it% n)#erical +al)e i% t"e %igned &rod)ct of it% %ignificand
and it% radi/ rai%ed to t"e &o.er 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' an
encoding.
3.2.2' fused*ultiplyAdd: T"e o&eration f)%edM)lti&l'Add==,y,4> co#&)te% == U y > R 4 a% if .it" )nbo)nded
range 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% of
t"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 in
t"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, and
re%tore. T"e ter# #ode #a' refer to t"e #ode &ara#eter =a% in Vro)nding direction #odeV> or it% +al)e =a% in
Vro)ndTo.ardJero #odeV>.
3.2.2 +a+: Aot a A)#ber, a %'#bolic floating&oint dat)#. T"ere are t.o t'&e% of AaA re&re%entation%:
()iet and %ignaling. Mo%t o&eration% &ro&agate )uiet +a+% .it"o)t %ignaling e/ce&tion%, and %ignal t"e
in+alid e/ce&tion ."en gi+en a signaling +a+ o&erand.
3.2.2" narro,er-,ider format: 0f t"e %et of floating&oint n)#ber% of one for#at i% a &ro&er %)b%et of
anot"er for#at, t"e fir%t i% called narro.er 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 %ignaling
an' 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)de
greater t"an or e()al to a #ini#)# b
e+in
+al)e. Aor#al n)#ber% can )%e t"e f)ll &reci%ion a+ailable in a
for#at. 0n 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 AaA, 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" a
re%)lt i% ro)nded.
3.2.3' pre.ailing mode: T"e +al)e of a #ode go+erning a &artic)lar in%tance of e/ec)tion of a co#&)tational
o&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 0111. All rig"t% re%er+ed. !age 16
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
3.2.33 radix: T"e ba%e for t"e re&re%entation of binar' or deci#al floating&oint n)#ber%, t.o or ten.
3.2.3 result: T"e floating&oint re&re%entation or encoding t"at i% deli+ered to t"e de%tination.
3.2.3" signal: F"en an o&eration "a% no o)tco#e %)itable for e+er' rea%onable a&&lication, t"at o&eration
#ig"t %ignal one or #ore e/ce&tion% b' in+o-ing t"e defa)lt "andling or, if e/&licitl' re()e%ted, a lang)age
defined alternate "andling.
3.2.3# significand: A co#&onent of a finite floating&oint n)#ber containing it% %ignificant digit%. T"e
%ignificand can be t"o)g"t of a% an integer, a fraction, or %o#e ot"er fi/ed&oint for#, b' c"oo%ing an
a&&ro&riate e/&onent off%et.
3.2.3$ status flag: A +ariable t"at #a' ta-e t.o %tate%, rai%ed or lo.ered. F"en rai%ed, a %tat)% flag #a'
con+e' additional %'%te#de&endent infor#ation, &o%%ibl' inacce%%ible to %o#e )%er%. T"e o&eration% of t"i%
%tandard, ."en e/ce&tional, can a% a %ide effect rai%e %o#e of t"e follo.ing %tat)% flag%: ine/act, )nderflo.,
o+erflo., di+ideb'Hero and in+alid.
3.2.3% storage format: One of t"e t.o %et% of floating&oint re&re%entation%, one binar' and one deci#al,
."o%e encoding% are %&ecified b' t"e %tandard, and ."ic" are not a+ailable for arit"#etic. A non-storage
format i% a ba%ic or e/tended for#at t"at i% not a %torage for#at.
3.2.3& su!normal num!er: 0n a &artic)lar for#at, a nonHero floating&oint n)#ber .it" #agnit)de le%% t"an
t"e #agnit)de of t"at for#atM% %#alle%t nor#al n)#ber. A %)bnor#al n)#ber cannot )%e t"e f)ll &reci%ion
a+ailable to nor#al n)#ber% of t"e %a#e for#at. S)&er%ede% 0111 Std $54N12B5M% (enor+a&i4e( nu+ber.
3.2.' supported format: A for#at &ro+ided in t"e &rogra##ing en+iron#ent and i#&le#ented in
confor#ance .it" t"e re()ire#ent% of t"i% %tandard. T")%, a &rogra##ing en+iron#ent #a' &ro+ide #ore
for#at% t"an it %)&&ort%, a% onl' t"o%e i#&le#ented in accordance .it" t"e %tandard are %aid to be %)&&orted.
An integer for#at i% %aid to be %)&&orted if con+er%ion% bet.een t"at for#at and %)&&orted floating&oint
for#at% are &ro+ided in confor#ance .it" t"i% %tandard.
3.2.1 trailing significand: A co#&onent of an encoded binar' or deci#al floating&oint n)#ber containing
all t"e %ignificand digit% e/ce&t t"e leading digit. 0n t"e%e for#at%, t"e bia%ed e/&onent or co#bination field
encode% t"e leading %ignificand digit.
3.2.2 user: An' &er%on, "ard.are, or &rogra# not it%elf %&ecified b' t"i% %tandard, "a+ing acce%% to and
controlling t"o%e o&eration% of t"e &rogra##ing en+iron#ent %&ecified in t"i% %tandard.
3.2.3 ,idth of an operation: T"e for#at of t"e de%tination of an o&eration %&ecified b' t"i% %tandardQ it .ill
be one of t"e %)&&orted for#at% &ro+ided b' an i#&le#entation in confor#ance to t"i% %tandard.
!age 14 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
4" Abbre-iation$ 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 0111. All rig"t% re%er+ed. !age 15
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
" Format$
"0
"! O-er-ie(% format$ and conformance
"!"0
T"i% cla)%e define% %e+eral -ind% of %tandard floating&oint for#at%, in t.o radice%, 2 and 10. All t"e for#at%
%&ecified b' t"i% %tandard are fi/ed.idt". T"e &reci%ion and range of a fi/ed.idt" 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 formats are for#at% .it" encoding% defined in t"i% %tandard. T"e' are .idel' a+ailable
for %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%. 0nterc"ange for#at% defined b' t"i% %tandard are
ba%ic or %torage:
L !asic formats are interc"ange for#at%, a+ailable for arit"#etic. T"i% %tandard define% t"ree
ba%ic binar' floating&oint for#at% in lengt"% of 62, 64, and 12B bit%, and t.o ba%ic deci#al
floating&oint for#at% in lengt"% of 64 and 12B bit%. A &rogra##ing en+iron#ent confor#% to
t"i% %tandard, in a &artic)lar radi/, b' i#&le#enting one or #ore of t"e ba%ic for#at% of t"at
radi/. T"e c"oice of %tandard for#at% i% lang)agedefined or, if t"e rele+ant lang)age %tandard
i% %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% bet.een 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' %torage
floating&oint for#at of 16 bit% lengt", and one deci#al %torage floating&oint for#at of 62 bit%
lengt". To %)&&ort a %torage for#at, t"i% %tandard onl' re()ire% t"at con+er%ion% be &ro+ided
bet.een 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 .ider
for#at%.
/ non-interchange formats are for#at% .it" no encoding% defined in t"i% %tandard. Aone are re()ired
b' t"i% %tandard. 0f 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 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
"2 S#ecification le-el$
"2"0
Floating&oint arit"#etic i% a %'%te#atic a&&ro/i#ation of real arit"#etic, a% ill)%trated in Table 1. Floating
&oint arit"#etic can onl' re&re%ent a finite %)b%et of t"e contin))# of real n)#ber%. :on%e()entl' certain
&ro&ertie% of real arit"#etic, %)c" a% a%%ociati+it' of addition, do not al.a'% "old for floating&oint
arit"#etic.
0a!le 112elationships !et,een different specification le.els for a particular format
"2"0
@e+el 1 345 6 / ' / 6 758 1/tended real n)#ber%.
#an'toone W roun(ing X oneto#an'
@e+el 2 345 6 4'8 37' 6 758 +a + Floating&oint data3
an algebraicall' clo%ed %'%te#.
oneto#an' W repre'entation 'pe*i,i*ation X #an'toone
@e+el 6 9sign: exponent: significand; 345: 758 )+a+ s+a+ Re&re%entation% of floating&oint
data.
oneto#an' W en*o(ing ,or repre'entation' o, ,&oatingpoint (ata X #an'toone
@e+el 4 '111'''6 ,it %tring%.
T"e #at"e#atical %tr)ct)re )nder&inning t"e arit"#etic in t"i% %tandard i% t"e e/tended real%, t"at i%, t"e %et of
real n)#ber% toget"er .it" &o%iti+e and negati+e infinit'. For a gi+en for#at, t"e &roce%% of roun(ing =%ee
:la)%e 6> #a&% an e/tended real n)#ber to a ,&oatingpoint (atu+ incl)ded in t"at for#at. A floating&oint
dat)#, ."ic" can be a %igned Hero, finite nonHero n)#ber, %igned infinit', or notan)#ber =AaA>, can be
#a&&ed to one or #ore repre'entation' o, ,&oatingpoint (ata in a for#at.
T"e re&re%entation% of floating&oint data in a for#at con%i%t of:
L tri&le% ='ign, e=ponent, 'igni,i*an(>Q in radi/ b, t"e floating&oint n)#ber re&re%ented b' a tri&le i%
=N1>
'ign
U b
e=ponent
U 'igni,i*an(
L RY, NY
L (AaA =()iet>, %AaA =%ignaling>
An en*o(ing #a&% a re&re%entation of a floating&oint dat)# to a bit %tring. An encoding #ig"t #a& %o#e
re&re%entation% of floating&oint data to #ore t"an one bit %tring. M)lti&le AaA bit %tring% #a' be )%ed to
%tore retro%&ecti+e diagno%tic infor#ation =%ee B.2>.
". Set$ of floating-#oint data
"."0
T"i% %)bcla)%e %&ecifie% t"e %et% of floating&oint data re&re%entable .it"in floating&oint for#at%Q t"e
encoding% for re&re%entation% of floating&oint data in interc"ange for#at% are di%c)%%ed in 5.4 and 5.5. T"e
%et of finite floating&oint n)#ber% re&re%entable .it"in a &artic)lar for#at i% deter#ined b' t"e follo.ing
integer &ara#eter%:
L b T t"e radi/, 2 or 10
L p T t"e n)#ber of %ignificant digit% =&reci%ion>
L e+a= T t"e #a/i#)# e/&onent
L e+in T t"e #ini#)# e/&onent
S"all be eit"er 1 N e+a= or ?e+a=)
S"o)ld be 1 ? e+a=)
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 1$
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 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 of
bit% in t"eir encoding. Fit"in eac" for#at, t"e follo.ing floating&oint data %"all be &ro+ided:
L Signed Hero and nonHero floating&oint n)#ber% of t"e for# =N1>
'
Ub
e
U+, ."ere:
L ' i% 0 or 1
L e i% an' integer e+in Z e Z e+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 0 Z (i \ b =t"erefore 0 Z + \ b>
L T.o infinitie%, RY and NY
L AaA
T"e%e are t"e onl' floating&oint data &ro+ided.
0n t"e foregoing de%cri&tion, t"e %ignificand + i% +ie.ed in a %cientific for#, .it" t"e radi/ &oint i##ediatel'
follo.ing t"e fir%t digit. 0t i% al%o con+enient for %o#e &)r&o%e% to +ie. t"e %ignificand a% an integerQ t"en t"e
finite 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+in Z >Rp ? 1 Z e+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 0 Z (i \ b =* i% t"erefore an integer .it" 0 Z * \ b
p
>.
T"i% +ie. of t"e %ignificand a% an integer, *, .it" it% corre%&onding e/&onent >, de%cribe% e/actl' t"e %a#e %et
of Hero and nonHero floating&oint n)#ber% a% t"e +ie. in %cientific for#. =For finite floating&oint n)#ber%,
e T > R p N 1 and + T *Ub
1Np
.>
T"e %#alle%t &o%iti+e nor+a& floating&oint n)#ber i% b
e+in
and t"e large%t i% b
e+a=
U=b ? b
1Np
>. T"e nonHero
floating&oint n)#ber% for a for#at .it" #agnit)de le%% t"an b
e+in
are called 'ubnor+a& beca)%e t"eir
#agnit)de% lie bet.een 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%. 1+er'
finite floating&oint n)#ber i% an integral #)lti&le of t"e %#alle%t %)bnor#al #agnit)de b
e+in
Ub
1Np
.
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 R0 and N0, t"e %ign of a Hero i% %ignificant in %o#e
circ)#%tance%, %)c" a% di+i%ion b' Hero, b)t not in ot"er% =%ee B.6>. ,inar' interc"ange for#at% "a+e *)%t one
re&re%entation eac" for R0 and S0, b)t deci#al for#at% "a+e #an'. 0n t"i% %tandard, 0 and Y are .ritten
.it"o)t a %ign ."en t"e %ign i% not i#&ortant.
0a!le 21Interchange format parameters defining floating-point num!ers
0
<inary format 9b=2; Decimal format 9b=1';
parameter
!inary1#
storage
!inary32
!asic
!inary#
!asic
!inary12%
!asic
decimal32
storage
decimal#
!asic
decimal12%
!asic
p digit% 11 24 56 116 $ 16 64
e+a= R15 R12$ R1026 R166B6 R26 R6B4 R6144
e+in N14 N126 N1022 N166B2 N25 N6B6 N6146
!age 1B :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
"4 3inar' interchange format encoding$
"4"0
1ac" 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 )ntil
eit"er e T e+in or + ] 1. After t"i% nor#aliHation &roce%% i% done, if e T e+in and + \ 1, t"e floating&oint
n)#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 follo.ing t"ree field% ordered a%
%"o.n in Fig)re 5.1:
a> 1bit %ign %
b> wbit bia%ed e/&onent E T e R bia'
c> =t T p ? 1>bit trailing %ignificand digit %tring T T (1 (2^(pN1Q t"e leading bit of t"e %ignificand, (0, i%
i#&licitl' encoded in t"e bia%ed e/&onent E)
Fig+re "!43inar' 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 6.
T"e range of t"e encodingM% bia%ed e/&onent E %"all incl)de:
L 1+er' integer bet.een 1 and 2
w
N 2, 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 2
w
N 1 to encode _Y and AaA%.
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, are
inferred fro# t"e con%tit)ent field% t")%:
a> 0f E T 2
w
N 1 and T A 0, t"en r i% (AaA or %AaA and v i% AaA regardle%% of %.
b> 0f E T 2
w
N 1 and T T 0 , t"en r and v T =N1>
%
UY.
c> 0f 1 Z E Z 2
w
N 2, t"en r i% =%, =E?bia'>, =1 R 2
1Np
UT>>Q
t"e +al)e of t"e corre%&onding floating&oint n)#ber i% v T =N1>
%
U2
E?bia'
U=1 R 2
1Np
UT>Q
t")% nor#al n)#ber% "a+e an i#&licit leading %ignificand bit of 1.
d> 0f E T 0 and T A 0, t"en r i% =%, e+in, =0 R 2
1Np
UT>>Q
t"e +al)e of t"e corre%&onding floating&oint n)#ber i% v T =N1>
%
U2
e+in
U=0 R 2
1Np
UT>Q
t")% %)bnor#al n)#ber% "a+e an i#&licit leading %ignificand bit of 0.
e> 0f E T 0 and T T 0 , t"en r i% =%, e+in, 0> and v T =N1>
%
U0 =%igned Hero, %ee B.6>.
Table .43inar' 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 0111. All rig"t% re%er+ed. !age 12
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
d
&
..................................................................................d
p-&
E
'
....................E
w-&
t ( p ) & bits & bit MS* w bits +S* MS* +S*
T
,trailing significand-
E
,biased exponent-
S
,sign-
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
" Decimal interchange format encoding$
""0
?nli-e in a binar' floating&oint for#at, in a deci#al floating&oint for#at a n)#ber #a' "a+e #)lti&le
re&re%entation%. T"e %et of re&re%entation% a floating&oint n)#ber #a&% to i% called t"e floating&oint
n)#ber`% *ohortQ t"e #e#ber% of a co"ort are di%tinct repre'entation' of t"e %a#e floating&oint n)#ber. For
e/a#&le, if * i% a #)lti&le of 10 and > i% le%% t"an t"e #a/i#)# e/&onent +al)e, t"en =', >, *> and =', > R 1,
* a 10> are t.o re&re%entation% for t"e %a#e floating&oint n)#ber and are #e#ber% of t"e %a#e co"ort.
F"ile n)#ericall' e()al, different #e#ber% of a co"ort can be di%ting)i%"ed b' t"e deci#al%&ecific
o&eration% =%ee $.10>. T"e co"ort% of different floating&oint n)#ber% #a' "a+e different n)#ber% of
#e#ber%. 0f a finite nonHero n)#berM% re&re%entation "a% n deci#al digit% fro# it% #o%t %ignificant nonHero
digit to it% lea%t %ignificant nonHero digit, t"e re&re%entation`% co"ort .ill "a+e at #o%t pnR1 #e#ber% ."ere
p i% t"e n)#ber of digit% of &reci%ion in t"e for#at.
For e/a#&le, a onedigit floating&oint n)#ber #ig"t "a+e )& to p different re&re%entation% ."ile a pdigit
floating&oint n)#ber .it" no trailing Hero% onl' "a% one re&re%entation. =An ndigit floating&oint n)#ber
#a' "a+e fe.er t"an p ? nR1 #e#ber% in it% co"ort if it i% near t"e e/tre#e% of t"e for#at`% e/&onent range.>
A Hero "a% a #)c" larger co"ort: t"e co"ort of R0 contain% a re&re%entation for eac" e/&onent, a% doe% t"e
co"ort of S0.
For deci#al arit"#etic, be%ide% %&ecif'ing a n)#erical re%)lt, t"e arit"#etic o&erand% al%o %elect a #e#ber of
t"e re%)lt`% co"ort according to t"e %&ecification in $.11. Traditional deci#al a&&lication% #a-e )%e of t"e
additional infor#ation co"ort% con+e'.
Re&re%entation% of floating&oint data in t"e deci#al interc"ange for#at% are encoded in t"e follo.ing t"ree
field%, ."o%e detailed la'o)t% are de%cribed later.
a> 1bit %ign %.
b> A w R 5 bit co#bination field B encoding cla%%ification and, if t"e encoded dat)# i% a finite n)#ber,
t"e e/&onent and fo)r %ignificand bit% =1 or 6 of ."ic" are i#&lied>. T"e bia%ed e/&onent E i% a w R 2
bit ()antit' > R bia', ."ere t"e +al)e of t"e fir%t t.o bit% of t"e bia%ed e/&onent ta-en toget"er i%
eit"er 0, 1, or 2.
c> A tbit trailing %ignificand field T ."ic" contain% ; U 10 bit% and contain% t"e b)l- of t"e %ignificand.
F"en t"i% field i% co#bined .it" t"e leading %ignificand bit% fro# t"e co#bination field, t"e for#at
encode% a total of p T 6 U ; R 1 deci#al digit%.
Fig+re "24Decimal interchange floating-#oint format$
MS, i% #o%t %ignificant bitQ @S, i% lea%t %ignificant bit.
!age 20 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
w+. bits t ( J

/

&' bits
G
'
...................G
01 decimal encoding2 J declets give 3/J ( p ) & digits
binary encoding2 t bits give values from ' through 4
t
-&
& bit MS* +S* MS* +S*
T
,trailing significand-
S
,sign-
G
,combination-
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
T"e +al)e% of w, bia', and t for t"e deci#al interc"ange for#at% are li%ted in Table 4:
0a!le 1Decimal interchange format encoding parameters
0
=ormat name parameter decimal32 decimal# decimal12%
Storage .idt" L 62 64 12B
Trailing %ignificand .idt" t 20 50 110
:o#bination field .idt" wR5 11 16 1$
,ia% E> 101 62B 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, are
inferred fro# t"e con%tit)ent field%, t")%:
a> 0f B0 t"ro)g" B8 are 11111, t"en v i% AaA regardle%% of %. F)rt"er#ore, if B5 i% 1, t"en r i% %AaAQ
ot"er.i%e r i% (AaA. T"e re#aining bit% of B are ignored, and T con%tit)te% t"e AaAM% &a'load,
."ic" can be )%ed to di%ting)i%" +ario)% AaA%.
T"e AaA &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% an
integer .it" a #a/i#)# +al)e of 10
=6U;>
S 1, and t"e e/&onent i% ignored =it i% treated a% if it .ere
Hero>. A AaA i% in it% &referred =canonical> re&re%entation if t"e bit% B6 t"ro)g" BwR4 are Hero and
t"e encoding of t"e &a'load i% canonical.
b> 0f B0 t"ro)g" B4 are 11110 t"en r and v T =S1>
%
U Y. T"e +al)e% of t"e re#aining bit% in B, and T, are
ignored. T"e t.o canonical re&re%entation% of infinit' "a+e bit% B5 t"ro)g" B.R4 T 0, and T T 0.
c> For finite n)#ber%, r i% =%, ESbia', C> and v T =S1>
%
U 10
=ESbia'>
U C, ."ere C i% t"e concatenation of
t"e leading %ignificand digit fro# t"e co#bination field B and t"e trailing %ignificand field T and t"e
bia%ed e/&onent E i% 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> 0f t"e %ignificand )%e% t"e (e*i+a& encoding, t"en t"e lea%t %ignificant w bit% of t"e e/&onent are
B5 t"ro)g" BwR4. T"e #o%t %ignificant t.o bit% of t"e bia%ed e/&onent and t"e deci#al digit
%tring (0 (1^(pS1 of t"e %ignificand are for#ed fro# bit% B0 t"ro)g" B4 and T a% follo.%:
i> F"en t"e fir%t fi+e bit% of B are 110// or 1110/, t"e leading %ignificand digit (0 i% B R B4, a
+al)e B or 2, and t"e leading bia%ed e/&onent bit% are 2B2RB6 , a +al)e 0, 1, or 2.
ii> F"en t"e fir%t fi+e bit% of B are 0//// or 10///, t"e leading %ignificand digit (0 i%
4B2R2B6RB4, a +al)e in t"e range 0^$, and t"e leading bia%ed e/&onent bit% are 2B0RB1, a
+al)e 0, 1, or 2. :on%e()entl' if T i% 0 and t"e fir%t fi+e bit% of B are 00000, 01000, or
10000, t"en v T =N1>
%
U 0.
T"e pS1T 6 U ; deci#al digit% (1^(pS1 are encoded b' T ."ic" contain% ; declet% encoded in
den%el'&ac-ed deci#al.
A canonical %ignificand "a% onl' canonical declet%, a% %"o.n in Table% 5 and 6. :o#&)tational
o&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 binary encoding, t"en
i> 0f B0 and B1 toget"er are one of 00, 01, or 10, t"en t"e bia%ed e/&onent E i% for#ed fro# B0
t"ro)g" BwR1 and t"e %ignificand i% for#ed fro# bit% BwR2 t"ro)g" t"e end of t"e encoding
=incl)ding T>.
ii> 0f B0 and B1 toget"er are 11 and B2 and B6 toget"er are one of 00, 01, or 10, t"en t"e bia%ed
e/&onent E i% for#ed fro# B2 t"ro)g" BwR6 and t"e %ignificand i% for#ed b' &refi/ing t"e 4
bit% =B R BwR4> to T.
0n 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"at
of t"e e()i+alent deci#alencoded %ignificandQ t"at i%, 10
=6U;R1>
S1 =or 10
=6U;>
S1 ."en T i% )%ed a%
t"e &a'load of a AaA>. 0f t"e +al)e e/ceed% t"e #a/i#)#, t"e %ignificand * i% noncanonical
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 21
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 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: Table 5 decode% a declet, .it" 10 bit% !9'; to !9&;: into 6 deci#al digit%
d91;: d92;: d93;. T"e fir%t col)#n i% in binar' and an O/P denote% Odon`t careP. T")% all 1024 &o%%ible 10bit
&attern% %"all be acce&ted and #a&&ed into 1000 &o%%ible 6digit co#bination% .it" %o#e red)ndanc'.
Table 4Decoding !0-bit den$el'-#ac5ed decimal to . decimal digit$
0
!9#;: !9$;: !9%;: !93;: !9; d91; d92; d93;
0 / / / / 4b=0> R 2b=1> R b=2> 4b=6> R 2b=4> R b=5> 4b=$> R 2b=B> R b=2>
1 0 0 / / 4b=0> R 2b=1> R b=2> 4b=6> R 2b=4> R b=5> B R b=2>
1 0 1 / / 4b=0> R 2b=1> R b=2> B R b=5> 4b=$> R 2b=B> R b=2>
1 1 0 / / B R b=2> 4b=6> R 2b=4> R b=5> 4b=$> R 2b=B> R b=2>
1 1 1 0 0 B R b=2> B R b=5> 4b=$> R 2b=B> R b=2>
1 1 1 0 1 B R b=2> 4b=6> R 2b=4> R b=5> B R b=2>
1 1 1 1 0 4b=0> R 2b=1> R b=2> B R b=5> B R b=2>
1 1 1 1 1 B R b=2> B R b=5> B R b=2>
?ncoding densely-pac>ed decimal: Table 6 encode% 6 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 and
bit 6 t"e lea%t %ignificant, into a declet, .it" 10 bit% !9'; to !9&;. :o#&)tational o&eration% generate onl' t"e
1000 canonical 10bit &attern% defined b' Table 6.
Table 64/ncoding . decimal digit$ to !0-bit den$el'-#ac5ed decimal
0
d91:';: d92:';: d93:'; !9';: !91;: !92; !93;: !9;: !9"; !9#; !9$;: !9%;: !9&;
0 0 0 d=1,1:6> d=2,1:6> 0 d=6,1:6>
0 0 1 d=1,1:6> d=2,1:6> 1 0, 0, d=6,6>
0 1 0 d=1,1:6> d=6,1:2>, d=2,6> 1 0, 1, d=6,6>
0 1 1 d=1,1:6> 1, 0, d=2,6> 1 1, 1, d=6,6>
1 0 0 d=6,1:2>, d=1,6> d=2,1:6> 1 1, 0, d=6,6>
1 0 1 d=2,1:2>, d=1,6> 0, 1, d=2,6> 1 1, 1, d=6,6>
1 1 0 d=6,1:2>, d=1,6> 0, 0, d=2,6> 1 1, 1, d=6,6>
1 1 1 0, 0, d=1,6> 1, 1, d=2,6> 1 1, 1, d=6,6>
T"e 24 noncanonical &attern% of t"e for# 01/11/111/, 10/11/111/, or 11/11/111/ =."ere an O/P denote%
Odon`t careP> are not generated in t"e re%)lt of a co#&)tational o&eration. 4o.e+er, a% li%ted in Table 5, t"e%e
24 bit &attern% do #a& to +al)e% in t"e range 0222. T"e bit &attern in a AaA %ignificand can affect "o. t"e
AaA i% &ro&agated =%ee B.2>.
!age 22 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
"6 6on-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% in 5.2 and 5.6.
?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 an
i#&le#entation t"at doe% not %)&&ort t"e .ide%t ba%ic for#at %"o)ld %)&&ort an e=ten(e( noninterc"ange
for#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 74/0tended format #arameter$ for floating-#oint n+mber$
0
?xtended formats associated ,ith:
@arameter !inary32 !inary# decimal#
p digits ] 62 64 20
emax ] 1026 166B6 6144
emin C S1022 N166B2 S6146
+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 bet.een t"e .ide%t %)&&orted ba%ic for#at and t"e ne/t .ider ba%ic for#at.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 26
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
6" 7ode$ and ro+nding
6"0
6"! 7ode $#ecification
6"!"0
A #ode i% an i#&licit &ara#eter to o&eration% of t"i% %tandard. All i#&le#entation% %"all &ro+ide t"e
ro)nding direction #ode% =%ee 6.2> and %"o)ld &ro+ide alternate e/ce&tion "andling #ode% =%ee Anne/ 1>.
Fit" con%tant#ode %&ecification, a )%er #a' %&ecif' a con%tant +al)e for a #ode &ara#eter. Fit" 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% of
tran%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#.
F"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)age
defined %'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. Fit"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 $.$.$.
0n t"e ab%ence of an' e/&licit %&ecification in t"e &rogra#, it i% lang)agedefined ."et"er t"e #ode &ara#eter
a%%)#e% t"e defa)lt #ode +al)e or t"e +al)e of a d'na#ic #ode +ariable.
T"e follo.ing 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"er
t"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% a
deb)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%tinationM%
for#at ."ile &er"a&% %ignaling t"e ine/act e/ce&tion =%ee 2.6>, )nderflo., or o+erflo.. 1+er' o&eration %"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 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. AonHero n)#eric
floating&oint re%)lt% al.a'% "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.6>, and doe% affect t"e t"re%"old%
be'ond ."ic" o+erflo. =%ee 2.4> and )nderflo. =%ee 2.5> are %ignaled.
0#&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)nding
direction #ode a%%ociated .it" t"e radi/ of t"e re%)lt%. O&eration% con+erting fro# an o&erand in internal
floating&oint for#at to a re%)lt in integer for#at or e/ternal c"aracter %e()ence for#at )%e t"e ro)nding
direction #ode a%%ociated .it" t"e radi/ of t"e o&erand.
!age 24 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
6"2"! Ro+nding direction mode$ to neare$t
6"2"!"0
0n t"e%e #ode% an infinitel' &reci%e re%)lt .it" #agnit)de at lea%t b
e+a=
=b N b b
1Sp
> %"all ro)nd to Y .it" no
c"ange in %ignQ "ere e+a= and p are deter#ined b' t"e de%tination for#at =%ee :la)%e 5.0>. Fit":
L ro)ndTie%To1+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%To1+en. 0t %"all be t"e defa)lt ro)nding
direction #ode for re%)lt% in binar' for#at%. T"e defa)lt ro)nding direction #ode for re%)lt% in
deci#al for#at% i% lang)agedefined, b)t %"o)ld be ro)ndTie%To1+en.
L ro)ndTie%ToA.a', 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 larger magnitude shall be delivered.
A decimal implementation of this standard shall provide roundTiesToAway as a user-selectable
rounding 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 directed
ro)nding #ode% ro)ndTo.ard!o%iti+e, ro)ndTo.ardAegati+e, and ro)ndTo.ardJero. Fit":
L ro)ndTo.ard!o%iti+e, t"e re%)lt %"all be t"e for#atM% floating&oint n)#ber =&o%%ibl' RY> clo%e%t to
and no le%% t"an t"e infinitel' &reci%e re%)lt.
L ro)ndTo.ardAegati+e, t"e re%)lt %"all be t"e for#atM% floating&oint n)#ber =&o%%ibl' NY> clo%e%t to
and no greater t"an t"e infinitel' &reci%e re%)lt.
L ro)ndTo.ardJero, t"e re%)lt %"all be t"e for#atM% 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 0111. All rig"t% re%er+ed. !age 25
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
7" O#eration$
7"0
7"! O-er-ie(
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. 1ac" of t"e
co#&)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 in
t"e de%tinationM% for#at =%ee :la)%e 6 and :la)%e 2>. :la)%e B a)g#ent% t"e follo.ing %&ecification% to co+er
_0, _Y, and AaAQ :la)%e 2 en)#erate% e/ce&tion% ca)%ed b' e/ce&tional o&erand% and e/ce&tional re%)lt%.
0n t"i% %tandard, o&eration% are .ritten a% na#ed f)nction%Q in a %&ecific &rogra##ing en+iron#ent t"e' #ig"t
be 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 to
:la)%e 6, and #ig"t %ignal t"e floating&oint e/ce&tion% of :la)%e 2,
L ()ietco#&)tational o&eration% &rod)ce floating&oint re%)lt% and do not %ignal floating&oint
e/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&oint
e/ce&tion%.
O&eration% in t"e fir%t t"ree gro)&% are referred to collecti+el' a% Oco#&)tational o&eration%.P
O&eration% are al%o cla%%ified in t.o .a'% according to t"e relation%"i& bet.een t"e re%)lt for#at and t"e
o&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"e
o&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&&ed
into t"e o&eration% of t"i% %tandard.
0n t"e o&eration de%cri&tion% t"at follo., o&erand for#at% are indicated b'
D 'our*e to re&re%ent "o#ogeneo)% floating&oint o&erand for#at%.
D 'our*e1, 'our*e2, 'our*eE to 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%tination ,or+at, ."ic" #ig"t
be different fro# t"e floating&oint o&erand%M for#at. T"ere are ,or+at., +er%ion% of t"e%e o&eration% for
e+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.
0n t"e o&eration de%cri&tion% t"at follo., lang)age% define ."ic" of t"eir t'&e% corre%&ond to o&erand% and
re%)lt% called int, intFor+at.,, *hara*ter%e>uen*e, or *onver'ion%pe*i,i*ation. @ang)age% .it" bot" %igned
and )n%igned integer t'&e% %"o)ld %)&&ort bot" %igned and )n%igned int and intFor+at., o&erand% and
re%)lt%.
7"2 Decimal e0#onent calc+lation
7"2"0
A% di%c)%%ed in 5.6, 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 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
Except for the quantize operation, the value of a floating-point result (and hence its cohort) is determined
by the operation and the operands' values; it is never dependent on the representation or encoding of an
operand.
T"e %election of a &artic)lar re&re%entation for a floating&oint re%)lt i% de&endent on t"e o&erand%M
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 on
t"e &referred e/&onent for a re%)lt of t"at o&eration. T")% for finite =, de&ending on t"e re&re%entation of
Hero, 0 R = #ig"t re%)lt in a different #e#ber of =`% co"ort.
0f 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/&onent
clo%e%t to t"e &referred e/&onent i% )%ed.
0n t"e de%cri&tion% t"at follo., c==> i% t"e e/&onent > of t"e re&re%entation of a finite floating&oint n)#ber =)
0f = i% infinite, c==> i% RY.
7". 8omogeneo+$ general-com#+tational o#eration$
7"."0
7"."! 2eneral o#eration$
7"."!"0
0#&le#entation% %"all &ro+ide t"e follo.ing "o#ogeneo)% generalco#&)tational o&eration% for all %)&&orted
non%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+at round0oIntegral0ies0o?.en='our*e>
'our*eFor+at round0oIntegral0ies0oA,ay='our*e>
'our*eFor+at round0oIntegral0o,ardAero='our*e>
'our*eFor+at round0oIntegral0o,ard@ositi.e='our*e>
'our*eFor+at round0oIntegral0o,ard+egati.e='our*e>
See $.2. T"e &referred e/&onent i% #a/=c==>, 0>.
L 'our*eFor+at round0oIntegral?xact='our*e>
See $.2. T"e &referred e/&onent i% #a/=c==>, 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 =) 0f = i%
t"e negati+e n)#ber of lea%t #agnit)de in =M% for#at, nextBp==> i% N0. nextBp=_0> i% t"e &o%iti+e
n)#ber of lea%t #agnit)de in =M% for#at. nextBp=RY> i% RY, and nextBp=NY> i% t"e finite negati+e
n)#ber large%t in #agnit)de. F"en = i% AaA, 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 0111. All rig"t% re%er+ed. !age 2$
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
D 'our*eFor+at nextAfter='our*e, 'our*e>
nextAfter(x, y) is the next floating-point number that neighbors x in the direction toward y, in the
format of x:
D 0f eit"er = or y i% AaA, t"en t"e re%)lt i% according to B.2.
D 0f = T y, t"en nextAfter==,y> i% co&'Sign==,y>.
D 0f = G y, t"en nextAfter==,y> i% ne/t?&==>Q if = H y, t"en nextAfter==,y> i% ne/tDo.n==>)
O+erflo. i% %ignaled ."en = i% finite b)t nextAfter==, y> i% infiniteQ )nderflo. i% %ignaled ."en
nextAfter==, y> lie% %trictl' bet.een _b
e+in
Q in bot" ca%e%, ine/act i% %ignaled.
T"e &referred e/&onent i% c==>.
L 'our*eFor+at remainder='our*e, 'our*e>
F"en yd0 , t"e re#ainder r T remainder==, y> i% defined regardle%% of t"e ro)nding direction #ode
b' t"e #at"e#atical relation r T = N y U n , ."ere n i% t"e integer neare%t t"e e/act n)#ber =7y Q
."ene+er e n N =7y e T b , t"en n i% e+en. T")%, t"e re#ainder i% al.a'% e/act. 0f r T 0 , it% %ign %"all be
t"at of =.
T"e &referred e/&onent i% #in=c==>, c=y>>.
D 'our*eFor+at min+um='our*e, 'our*e>
'our*eFor+at max+um='our*e, 'our*e>
'our*eFor+at min+um*ag='our*e, 'our*e>
'our*eFor+at max+um*ag='our*e, 'our*e>
min+um==,y> i% t"e canonical floating&oint n)#ber = if = \ y, 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 AaA. Ot"er.i%e it i% eit"er =
or y.
max+um==,y> i% t"e canonical floating&oint n)#ber y if = \ 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 AaA. Ot"er.i%e it i% eit"er =
or y.
min+um*ag==,y> i% = if e=e \ eye, y if eye \ e=e, ot"er.i%e #inA)#==,y>.
max+um*ag==,y> i% = if e=e f eye, y if eye f e=e, otherwise maxNum(x,y).
T"e &referred e/&onent i% c==> if = i% t"e re%)lt, c=y> if y i% t"e re%)lt.
7"."2 Decimal o#eration
7"."2"0
0#&le#entation% %)&&orting deci#al for#at% %"all &ro+ide t"e follo.ing "o#ogeneo)% generalco#&)tational
o&eration for all %)&&orted non%torage deci#al floating&oint for#at%. 0t ne+er &ro&agate% noncanonical
re%)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% = and y of t"e %a#e for#at, )uanti(e==, y> i% a floating&oint n)#ber in
t"e %a#e for#at ."ic" "a% t"e %a#e n)#erical +al)e a% = and t"e %a#e ()ant)# a% y) 0f 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"e
re%)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% =. 0f t"e e/&onent i% being decrea%ed and t"e %ignificand of t"e re%)lt .o)ld
"a+e #ore t"an p digit%, in+alid i% %ignaled and t"e re%)lt i% AaA. 0f one or bot" o&erand% are AaA
t"e r)le% in B.2 are follo.ed. Ot"er.i%e if onl' one o&erand i% infinite t"en in+alid i% %ignaled and t"e
re%)lt i% AaA. 0f bot" o&erand% are infinite t"en t"e re%)lt i% canonical Y .it" t"e %ign of =. ()antiHe
doe% not %ignal )nderflo. or o+erflo..
The preferred exponent is Q(y).
!age 2B :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
7".". logBFormat o#eration$
7"."."0
0#&le#entation% %"all &ro+ide t"e follo.ing generalco#&)tational o&eration% for all %)&&orted non%torage
floating&oint for#at%. For eac" %)&&orted non%torage floating&oint for#at, lang)age% define an a%%ociated
&og3For+at to contain t"e integral +al)e% of log,==>. T"e &og3For+at #ig"t be a floating&oint for#at or an
integer for#at. T"e &og3For+at %"all incl)de all integer% bet.een _2U=e+a= R p> incl)%i+e, ."ic" incl)de%
t"e %cale factor% for %caling bet.een 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>.
0f &og3For+at i% a floating&oint for#at, t"en t"e follo.ing o&eration% are "o#ogeneo)%. 0f &og3For+at i% an
integer 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+at log<='our*e>
log<==> i% t"e e/&onent e of =, a %igned integral +al)e, deter#ined a% t"o)g" = .ere re&re%ented .it"
infinite range and #ini#)# e/&onent. T")% ."en = i% &o%iti+e and finite,
1 Z %cale,==, Nlog<==>> \ b.
F"en &og3For+at i% a floating&oint for#at, log<=AaA> i% a AaA, log<=Y> i% 7Y, and log<=0> i% N
Y and %ignal% t"e di+i%ion b' Hero e/ce&tion. F"en &og3For+at i% an integer for#at, t"en
log<=AaA>, log<=Y>, and log<=0> are lang)agedefined +al)e% o)t%ide t"e range
_2U=e+a=RpN1>, and %ignal t"e in+alid e/ce&tion.
T"e &referred e/&onent i% 0.
D 'our*eFor+at scale<='our*e, &og3For+at>
scale<==, N> i% = U b
N
for integral +al)e% N) T"e re%)lt i% co#&)ted a% if t"e e/act &rod)ct .ere
for#ed and t"en ro)nded to t"e de%tination for#at, %)b*ect to t"e &re+ailing ro)nding direction
#ode.
T"e &referred e/&onent i% c==>IN.
7"4 formatOf general-com#+tational o#eration$
7"4"0
7"4"! Arithmetic o#eration$
7"4"!"0
0#&le#entation% %"all &ro+ide t"e follo.ing ,or+at., generalco#&)tational o&eration%, for de%tination% of
all %)&&orted non%torage floating&oint for#at%, and, for eac" de%tination for#at, for o&erand% of all
%)&&orted non%torage floating&oint for#at% .it" t"e %a#e radi/ a% t"e de%tination for#at. T"e%e o&eration%
ne+er &ro&agate noncanonical re%)lt%.
D ,or+at.,addition='our*e1, 'our*e2>
,or+at.,su!traction='our*e1, 'our*e2>
,or+at.,multiplication='our*e1, 'our*e2>
,or+at.,di.ision='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) for
multiplication, and Q(x) Q(y) for the division x/y.
D ,or+at.,s)uare2oot='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*eE>
T"e o&eration fused*ultiplyAdd==,y,4> co#&)te% ==Uy>R4 a% if .it" )nbo)nded range and &reci%ion,
ro)nding onl' once to t"e de%tination for#at. Ao )nderflo., o+erflo., or ine/act e/ce&tion =:la)%e
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 22
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
2> 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 follo.ed 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=c==> R c=y>, c=H>>.
D ,or+at.,con.ert9int>
0t %"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%. 0ntegral +al)e% are con+erted e/actl' fro# integer
for#at% to floating&oint for#at% ."ene+er t"e +al)e i% re&re%entable in bot" for#at%. 0f t"e
con+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#ined
according to t"e &re+ailing ro)nding direction #ode, and an ine/act or floating&oint o+erflo.
e/ce&tion ari%e% a% %&ecified in :la)%e 2, *)%t a% .it" arit"#etic o&eration%.
T"e &referred e/&onent i% 0.
0#&le#entation% %"all &ro+ide t"e follo.ing 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.,con.ert0oInteger0ies0o?.en='our*e>
intFor+at.,con.ert0oInteger0o,ardAero='our*e>
intFor+at.,con.ert0oInteger0o,ard@ositi.e='our*e>
intFor+at.,con.ert0oInteger0o,ard+egati.e='our*e>
intFor+at.,con.ert0oInteger0ies0oA,ay='our*e>
See $.B for detail%.
D intFor+at.,con.ert0oInteger?xact0ies0o?.en='our*e>
intFor+at.,con.ert0oInteger?xact0o,ardAero='our*e>
intFor+at.,con.ert0oInteger?xact0o,ard@ositi.e='our*e>
intFor+at.,con.ert0oInteger?xact0o,ard+egati.e='our*e>
intFor+at.,con.ert0oInteger?xact0ies0oA,ay='our*e>
See $.B for detail%.
7"4"2 )on-er$ion o#eration$ for all format$
7"4"2"0
0#&le#entation% %"all &ro+ide t"e follo.ing ,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%ion
o&eration% &rod)ce re%)lt% in a different radi/ t"an t"e o&erand%.
D ,or+at.,con.ert='our*e>
0f t"e con+er%ion i% to a for#at in a different radi/ or to a narro.er &reci%ion in t"e %a#e radi/, t"e
re%)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)t
.ider &reci%ion and range i% al.a'% 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% bet.een internal deci#al for#at%, t"e &referred e/&onent i% c='our*e>.
D ,or+at.,con.ert=romDecimalCharacter=(e*i+a&Chara*ter%e>uen*e>
See $.12.6. T"e &referred e/&onent i% c=(e*i+a&Chara*ter%e>uen*e>.
D (e*i+a&Chara*ter%e>uen*e con.ert0oDecimalCharacter='our*e, *onver'ion%pe*i,i*ation>
See $.12.6. T"e *onver'ion%pe*i,i*ation %&ecifie% t"e &reci%ion and for#atting of t"e
(e*i+a&Chara*ter%e>uen*e re%)lt.
7"4". )on-er$ion o#eration$ for binar' format$
7"4"."0
0#&le#entation% %"all &ro+ide t"e follo.ing ,or+at., con+er%ion o&eration% to and fro# all %)&&orted binar'
floating&oint for#at%, incl)ding %torage for#at%.
!age 60 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
D ,or+at.,con.ert=romDexCharacter=he=Chara*ter%e>uen*e>
See $.12.2.
D he=Chara*ter%e>uen*e con.ert0oDexCharacter='our*e, *onver'ion%pe*i,i*ation>
See $.12.2. T"e *onver'ion%pe*i,i*ation %&ecifie% t"e &reci%ion and for#atting of t"e
he=Chara*ter%e>uen*e re%)lt.
7" 8omogeneo+$ 9+iet-com#+tational o#eration$
7""0
7""! Sign o#eration$
7""!"0
0#&le#entation% %"all &ro+ide t"e follo.ing "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 AaA% ali-e, and "ence %ignal no
e/ce&tion.
D 'our*eFor+at copy='our*e>
'our*eFor+at negate='our*e>
'our*eFor+at a!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% ?= or negate==>.
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% c==>.
D 'our*eFor+at copyEign='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 of y.
T"e &referred e/&onent i% c==>.
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 follo.ing o&eration% to
con+ert bet.een t"e internal deci#al for#at and t"e t.o %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#entationM% encoding for deci#al t'&e% to acce%%
data re&re%ented .it" eit"er %tandard encoding.
D (e*i+a&En*o(ingType encodeDecimal=(e*i+a&Type>:
encode% t"e +al)e of t"e o&erand )%ing deci#al encoding
D (e*i+a&Type decodeDecimal=(e*i+a&En*o(ingType>:
decode% t"e deci#alencoded o&erand
D binaryEn*o(ingType encode<inary=(e*i+a&Type>:
encode% t"e +al)e of t"e o&erand )%ing t"e binar' encoding
D (e*i+a&Type decode<inary9binaryEn*o(ingType>:
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&oint
data, binaryEn*o(ingType i% a lang)agedefined t'&e for %toring binar'encoded deci#al floating&oint data,
and (e*i+a&Type i% t"e t'&e of t"e gi+en deci#al floating&oint for#at.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 61
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
7"6 Signaling-com#+tational o#eration$
7"6"0
7"6"! )om#ari$on$
7"6"!"0
0#&le#entation% %"all &ro+ide t"e follo.ing 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 62 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
7"6"2 /0ce#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=*eptionBroupType o&erand, ."ic" can re&re%ent an' %)b%et
of t"e e/ce&tion%.
F"et"er %ignal1/ce&tion additionall' %ignal% t"e ine/act e/ce&tion ."ene+er it %ignal% o+erflo. or
)nderflo. i% lang)age defined. 0f %ignal1/ce&tion %ignal% o+erflo. and ine/act or )nderflo. and ine/act, t"en
it %ignal% o+erflo. or )nderflo. before ine/act. Ot"er.i%e, t"e order in ."ic" t"e e/ce&tion% are %ignaled i%
)n%&ecified.
7"7 6on-com#+tational o#eration$
7"7"0
7"7"! )onformance #redicate$
0#&le#entation% %"all &ro+ide t"e follo.ing nonco#&)tational o&eration%, tr)e if and onl' if t"e indicated
condition% 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 AAS00111 Std $5412B5.
D boo&ean is$"2=voi(>
is$"2=> 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 2eneral o#eration$
7"7"2"0
0#&le#entation% %"all &ro+ide t"e follo.ing nonco#&)tational o&eration% for all %)&&orted non%torage
floating&oint for#at%. T"e' are ne+er e/ce&tional, e+en for %ignaling AaA%.:
D boo&ean isEigned='our*e>
isEigned==> i% tr)e if and onl' if = "a% negati+e %ign. isEigned a&&lie% to Hero% and AaA% a% .ell.
D boo&ean is+ormal='our*e>
is+ormal==> i% tr)e if and onl' if = i% nor#al =not Hero, %)bnor#al, infinit', or AaA>.
D boo&ean is=inite='our*e>
is=inite==> i% tr)e if and onl' if = i% Hero, %)bnor#al or nor#al =not infinit' or AaA>.
D boo&ean isAero='our*e>
isAero==> i% tr)e if and onl' if = T _0.
D boo&ean isEu!normal='our*e>
isEu!normal==> i% tr)e if and onl' if = i% %)bnor#al.
D boo&ean isInfinity='our*e>
isInfinity==> i% tr)e if and onl' if = i% infinite.
D boo&ean is+a+='our*e>
is+a+==> i% tr)e if and onl' if = i% a AaA.
D boo&ean isEignaling='our*e>
isEignaling==> i% tr)e if and onl' if = i% a %ignaling AaA.
D boo&ean isCanonical='our*e>
isCanonical==> i% tr)e if and onl' if = i% a finite n)#ber, infinit', or AaA t"at i% canonical.
0#&le#entation% %"o)ld e/tend isCanonical==> to noninterc"ange for#at% in .a'% a&&ro&riate to
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 66
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
t"o%e for#at%, ."ic" #ig"t, or #ig"t not, "a+e finite n)#ber%, infinitie%, or AaA% t"at are non
canonical.
D int radix='our*e>
radix==> i% t"e radi/ b of t"e for#at of =, 2 or 10.
D enu+ class='our*e>
class==> tell% ."ic" of t"e follo.ing ten cla%%e% = fall% into:
%ignalingAaA
()ietAaA
negati+e0nfinit'
negati+eAor#al
negati+eS)bnor#al
negati+eJero
&o%iti+eJero
&o%iti+eS)bnor#al
&o%iti+eAor#al
&o%iti+e0nfinit'
D boo&ean totalHrder='our*e, 'our*e>
totalHrder==, y> i% defined in $.10.
D boo&ean totalHrder*ag='our*e, 'our*e>
totalHrder*ag==, y> i% totalHrder=ab%==>,ab%=y>>.
7"7". Decimal o#eration
7"7"."0
0#&le#entation% %)&&orting deci#al for#at% %"all &ro+ide t"e follo.ing nonco#&)tational o&eration for all
%)&&orted non%torage deci#al floating&oint for#at%:
D boo&ean sameGuantum='our*e,'our*e>
For n)#erical deci#al o&erand% = and y of t"e %a#e for#at, sameGuantum==, y> i% tr)e if t"e
e/&onent% of = and y are t"e %a#e, i.e. c==> T c=y>, and fal%e ot"er.i%e. sameGuantum=AaA, AaA>
and sameGuantum=5, 5> are tr)eQ if e/actl' one o&erand i% infinite or e/actl' one o&erand i% AaA,
sameGuantum i% fal%e. sameGuantum %ignal% no e/ce&tion.
7"7"4 O#eration$ on $+b$et$ of flag$
7"7"4"0
0#&le#entation% %"all &ro+ide t"e follo.ing nonco#&)tational o&eration% t"at act )&on #)lti&le %tat)% flag%
collecti+el':
D voi( lo,er=lag=e=*eptionBroupType>:
lowers (clears) the flags corresponding to the exceptions specified in the exceptionGroupType
operand, which can represent any subset of the exceptions.
D boo&ean test=lag=e=*eptionBroupType>:
queries whether any of the flags corresponding to the exceptions specified in the
exceptionGroupType operand, which can represent any subset of the exceptions, are raised.
D voi( restore=lag=,&ag'Type, e=*eptionBroupType>:
restores the flags corresponding to the exceptions specified in the exceptionGroupType operand,
which can represent any subset of the exceptions, to their state represented in the flagsType
operand (see saveFlags in 7.7.5).
!age 64 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
7"7" O#eration$ on all flag$
7"7""0
0#&le#entation% %"all &ro+ide t"e follo.ing nonco#&)tational o&eration% t"at act )&on all %tat)% flag%
collecti+el':
D ,&ag'Type sa.e=lags=voi(>
ret)rn% a re&re%entation of t"e %tate of all t"e flag%. T"e ret)rn +al)e% of t"e sa.e=lags o&eration are
for )%e a% t"e fir%t o&erand to t"e re%toreFlag o&eration in t"e %a#e &rogra#Q t"i% %tandard doe% not
re()ire %)&&ort for an' ot"er )%e.
7"7"6 O#eration$ on indi-id+al mode$
7"7"6"0
0#&le#entation% %"all &ro+ide t"e follo.ing nonco#&)tational o&eration% for eac" %)&&orted MOD1 =%ee
cla)%e 6>:
D 6.7Etype get*HD?=voi(>
get &re+ailing +al)e of MOD1. ?nder con%tant %&ecification for MOD1, get*HD? ret)rn% t"e
con%tant +al)e. ?nder d'na#ic %&ecification for MOD1, get*HD? ret)rn% t"e c)rrent +al)e of t"e
d'na#ic MOD1 +ariable. 1l%e."ere, t"e ret)rn +al)e i% lang)age defined =and #a' be )n%&ecified>.
For t"e ro)nding direction #ode%, t"e get*HD? o&eration% are:
D binary/oun(ing7ire*tionType get<inary2oundingDirection=voi(>
D (e*i+a&/oun(ing7ire*tionType getDecimal2oundingDirection=voi(>
Fit" con%tant MOD1 %&ecification, t"e +al)e of t"e #ode i% %et b' t"e %&ecification directi+e it%elf.
0#&le#entation% %)&&orting con%tant %&ecification for MOD1 =a% defined b' t"e lang)age> %"all &ro+ide for
con%tant %&ecification of t"e defa)lt and eac" %&ecific +al)e of t"e #ode.
0#&le#entation% %)&&orting d'na#ic %&ecification for MOD1 %"all &ro+ide t"e follo.ing nonco#&)tational
o&eration:
D voi( set*HD?=6.7Etype>
%et t"e +al)e of t"e d'na#ic #ode +ariable. T"e o&erand #a' be an' of t"e lang)agedefined
re&re%entation% for t"e defa)lt and eac" %&ecific +al)e of MOD1. T"e effect of t"i% o&eration if )%ed
o)t%ide t"e %tatic %co&e of a d'na#ic %&ecification for MOD1 i% lang)age defined =and #a' be
)n%&ecified>.
For t"e ro)nding direction #ode%, t"e set*HD? o&eration% are:
D voi( set<inary2oundingDirection=binary/oun(ing7ire*tionType>
D voi( setDecimal2oundingDirection=(e*i+a&/oun(ing7ire*tionType>
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 65
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
7"7"7 O#eration$ on all mode$ (ith d'namic $#ecification
7"7"7"0
0#&le#entation% %)&&orting d'na#ic %&ecification for #ode% %"all &ro+ide t"e follo.ing nonco#&)tational
o&eration% for all d'na#ic%&ecifiable #ode% collecti+el':
D +o(eBroupType sa.e*odes9voi(>
%a+e +al)e% of all d'na#ic%&ecifiable #ode% a% a gro)&
D voi( restore*odes=+o(eBroupType>
re%tore +al)e% of all d'na#ic%&ecifiable #ode% a% a gro)&
D voi( default*odes=voi(>
%et all d'na#ic%&ecifiable #ode% to defa)lt +al)e%
T"e ret)rn +al)e% of t"e %a+eMode% o&eration are for )%e a% o&erand% of t"e re%toreMode% o&eration in t"e
%a#e &rogra#Q t"i% %tandard doe% not re()ire %)&&ort for an' ot"er )%e.
T"e effect of t"e%e o&eration% if )%ed o)t%ide t"e %co&e of a d'na#ic %&ecification for a d'na#ic%&ecifiable
#ode i% lang)age defined =and #a' be )n%&ecified>.
7": Detail$ of con-er$ion$ from floating-#oint to integer format$
7":"0
0#&le#entation% %"all &ro+ide con+er%ion o&eration% fro# all %)&&orted non%torage floating&oint for#at% to
all %)&&orted %igned and )n%igned integer for#at%. 0ntegral +al)e% are con+erted e/actl' fro# floating&oint
for#at% to integer for#at% ."ene+er t"e +al)e i% re&re%entable in bot" for#at%.
:on+er%ion to integer %"all be effected b' ro)nding a% %&ecified in :la)%e 6, b)t t"e ro)nding direction i%
indicated b' t"e o&eration na#e.
F"en a AaA o&erand cannot be re&re%ented in t"e de%tination for#at and t"i% cannot ot"er.i%e be indicated,
t"e in+alid e/ce&tion %"all be %ignaled. F"en a n)#eric o&erand .o)ld con+ert to an integer o)t%ide t"e
range of t"e de%tination for#at, t"e in+alid e/ce&tion %"all be %ignaled if t"i% %it)ation cannot ot"er.i%e be
indicated.
F"en t"e ro)ndedtointegral floating&oint +al)e of t"e con+er%ion o&erationM% o&erand differ% fro# it%
o&erand +al)e, 'et i% re&re%entable in t"e de%tination for#at, t"e ine/act e/ce&tion #ig"t be %ignaled in
certain circ)#%tance%:
T"e ine/act e/ce&tion %"o)ld be %ignaled if an ine/act con+er%ion .a% in+o-ed b' a lang)ageM% r)le% for
i#&licit con+er%ion% or e/&re%%ion% in+ol+ing #i/ed t'&e%.
T"e o&eration% for con+er%ion fro# floating&oint to a %&ecific %igned or )n%igned integer for#at .it"o)t
%ignaling ine/act are:
D intFor+at.,con.ert0oInteger0ies0o?.en==> ro)nd% = to t"e neare%t integral +al)e, .it" "alf.a'
ca%e% ro)nded to e+en.
D intFor+at.,con.ert0oInteger0o,ardAero==> ro)nd% = to an integral +al)e to.ard Hero.
D intFor+at.,con.ert0oInteger0o,ard@ositi.e==> ro)nd% = to an integral +al)e to.ard &o%iti+e
infinit'.
D intFor+at.,con.ert0oInteger0o,ard+egati.e==> ro)nd% = to an integral +al)e to.ard negati+e
infinit'.
D intFor+at.,con.ert0oInteger0ies0oA,ay==> ro)nd% = to t"e neare%t integral +al)e, .it" "alf.a'
ca%e% ro)nded a.a' fro# Hero.
T"e o&eration% for con+er%ion fro# floating&oint to a %&ecific %igned or )n%igned integer for#at, %ignaling if
ine/act, are:
D intFor+at.,con.ert0oInteger?xact0ies0o?.en==>
ro)nd% = to t"e neare%t integral +al)e, .it" "alf.a' ca%e% ro)nded to e+en.
D intFor+at.,con.ert0oInteger?xact0o,ardAero==>
ro)nd% = to an integral +al)e to.ard Hero.
D intFor+at.,con.ert0oInteger?xact0o,ard@ositi.e==>
ro)nd% = to an integral +al)e to.ard &o%iti+e infinit'.
!age 66 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
D intFor+at.,con.ert0oInteger?xact0o,ard+egati.e==>
ro)nd% = to an integral +al)e to.ard negati+e infinit',
D intFor+at.,con.ert0oInteger?xact0ies0oA,ay==>
ro)nd% = to t"e neare%t integral +al)e, .it" "alf.a' ca%e% ro)nded a.a' fro# Hero.
7"; Detail$ of o#eration$ to ro+nd a floating-#oint dat+m to integral -al+e
7";"0
Se+eral o&eration% ro)nd a floating&oint n)#ber to an integral +al)ed floating&oint n)#ber in t"e %a#e
for#at.
T"e ro)nding i% analogo)% to t"at %&ecified in :la)%e 6, b)t t"e ro)nding c"oo%e% onl' fro# a#ong t"o%e
floating&oint n)#ber% of integral +al)e% in t"e for#at. T"e%e o&eration% con+ert Hero o&erand% to Hero re%)lt%
of t"e %a#e %ign, and infinite o&erand% to infinite re%)lt% of t"e %a#e %ign.
For t"e follo.ing o&eration%, t"e ro)nding direction i% i#&lied b' t"e o&eration na#e and doe% not de&end on
a ro)nding direction #ode. T"e%e o&eration% do not %ignal an' e/ce&tion e/ce&t for %ignaling AaA in&)t.
D 'our*eFor+at round0oIntegral0ies0o?.en==>
ro)nd% = to t"e neare%t integral +al)e, .it" "alf.a' ca%e% ro)nding to e+en.
D 'our*eFor+at round0oIntegral0o,ardAero==>
ro)nd% = to an integral +al)e to.ard Hero.
D 'our*eFor+at round0oIntegral0o,ard@ositi.e==>
ro)nd% = to an integral +al)e to.ard &o%iti+e infinit'.
D 'our*eFor+at round0oIntegral0o,ard+egati.e==>
ro)nd% = to an integral +al)e to.ard negati+e infinit'.
D 'our*eFor+at round0oIntegral0ies0oA,ay==>
ro)nd% = to t"e neare%t integral +al)e, .it" "alf.a' ca%e% ro)nding a.a' fro# Hero.
For t"e follo.ing o&eration, t"e ro)nding direction i% t"e &re+ailing ro)nding direction #ode. T"i% o&eration
%ignal% in+alid for %ignaling AaA, and for a n)#erical o&erand, %ignal% ine/act if t"e re%)lt i% not identical to
t"e o&erand.
D 'our*eFor+at round0oIntegral?xact==> ro)nd% = to an integral +al)e according to t"e &re+ailing
ro)nding direction #ode.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 6$
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
7"!0 Detail$ of totalOrder #redicate
7"!0"0
For eac" %)&&orted non%torage floating&oint for#at, an i#&le#entation %"all &ro+ide certain &redicate% t"at
define ordering% a#ong all o&erand% in a &artic)lar for#at.
totalOrder==,y> i#&o%e% a total ordering on canonical #e#ber% of t"e for#at of = and yQ
a> if = \ y, totalOrder==, y> i% tr)e
b> if = f y, totalOrder==, y> i% fal%e
c> if = T y:
1> totalOrder=S0, R0> i% tr)e
2> totalOrder=R0, S0> i% fal%e
6> if = and y re&re%ent t"e %a#e floating&oint dat)#:
i> if = and y "a+e negati+e %ign,
totalOrder==, y> if and onl' if t"e e/&onent of = ] t"e e/&onent of y
ii> ot"er.i%e
totalOrder==, y> if and onl' if t"e e/&onent of = Z t"e e/&onent of y
Aote t"at totalOrder doe% not i#&o%e a total ordering on all encoding% in a for#at. 0n &artic)lar
it doe% not di%ting)i%" a#ong different encoding% of t"e %a#e floating&oint re&re%entation, a%
."en one or bot" encoding% are noncanonical.
d> if = and y are )nordered n)#ericall' beca)%e = or y i% AaA:
1> totalOrder=SAaA, y> i% tr)e ."ere SAaA re&re%ent% a AaA .it" negati+e %ign bit and y i% a
floating&oint n)#ber.
2> totalOrder==, RAaA> i% tr)e ."ere RAaA re&re%ent% a AaA .it" &o%iti+e %ign bit and = i% a
floating&oint n)#ber.
6> if = and y are bot" AaA%, t"en totalOrder reflect% a total ordering ba%ed on
i> negati+e %ign bit \ &o%iti+e %ign bit
ii> %ignaling \ ()iet for RAaA, re+er%e for SAaA
iii> le%%er &a'load \ greater &a'load for RAaA, re+er%e for SAaA
Aeit"er %ignaling nor ()iet AaA% %ignal an e/ce&tion.
For canonical = and y, totalOrder==,y> and totalOrder=y,=> are bot" tr)e onl' if = and y are bit.i%e identical.
7"!! Detail$ of com#ari$on #redicate$
7"!!"0
For e+er' %)&&orted non%torage floating&oint for#at, it %"all be &o%%ible to co#&are one floating&oint
dat)# to anot"er in t"at for#at. Additionall', floating&oint data re&re%ented in different for#at% %"all be
co#&arable a% long a% t"e o&erand%M for#at% "a+e t"e %a#e radi/.
:o#&ari%on% are e/act and ne+er o+erflo. or )nderflo.. Fo)r #)t)all' e/cl)%i+e relation% are &o%%ible: &e''
than, e>ua&, greater than, and unor(ere(. T"e la%t ca%e ari%e% ."en at lea%t one o&erand i% AaA. 1+er' AaA
%"all co#&are unor(ere( .it" e+er't"ing, incl)ding it%elf. :o#&ari%on% %"all ignore t"e %ign of Hero
=%o R0 T S0>. 0nfinite o&erand% of t"e %a#e %ign %"all co#&are e>ua&.
@ang)age% define "o. t"e re%)lt of a co#&ari%on %"all be deli+ered, in one of t.o .a'%: eit"er a% a condition
code identif'ing one of t"e fo)r relation% li%ted abo+e, or a% a tr)efal%e re%&on%e to a &redicate t"at na#e% t"e
%&ecific co#&ari%on de%ired.
Table B, Table 2, and Table 10 e/"ibit t.ent' f)nctionall' di%tinct )%ef)l &redicate% and negation% .it"
+ario)% ad"oc and traditional na#e% and %'#bol%. 1ac" &redicate i% tr)e if an' of t"e it% indicated condition
code% i% tr)e. T"e condition code OgP indicate% an unor(ere( relation. Table 2 li%t% fo)r )nordered%ignaling
&redicate% and t"eir negation% t"at ca)%e an in+alid o&eration e/ce&tion ."en t"e relation i% )nordered. T"at
in+alid e/ce&tion defend% again%t )ne/&ected ()iet AaA% ari%ing in &rogra#% .ritten )%ing t"e %tandard
&redicate% ;\, Z, ], f< and t"eir negation%, .it"o)t con%idering t"e &o%%ibilit' of a ()iet AaA o&erand.
!rogra#% t"at e/&licitl' ta-e acco)nt of t"e &o%%ibilit' of ()iet AaA o&erand% #a' )%e t"e )nordered()iet
&redicate% in Table 10 ."ic" do not %ignal %)c" an in+alid e/ce&tion.
!age 6B :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
Aote t"at &redicate% co#e in &air%, eac" a logical negation of t"e ot"erQ a&&l'ing a &refi/ %)c" a% AOT to
negate a &redicate in Table B, Table 2, and Table 10 re+er%e% t"e tr)e7fal%e %en%e of it% a%%ociated entrie%, b)t
doe% not c"ange ."et"er unor(ere( relation% ca)%e an in+alid o&eration e/ce&tion.
T"e )nordered()iet &redicate% in Table B do not %ignal an e/ce&tion on ()iet AaA o&erand%:
Table :4Re9+ired +nordered-9+iet #redicate and negation
Bnordered-)uiet predicate Bnordered-)uiet negation
0rue relations +ames 0rue relations +ames
1c co#&are1()al
T
@T GT ?A co#&areAot1()al
g\f
AOT=T>
d
T"e )nordered%ignaling &redicate% in Table 2, intended for )%e b' &rogra#% not .ritten to ta-e into acco)nt
t"e &o%%ibilit' of AaA o&erand%, %ignal an in+alid e/ce&tion on ()iet AaA o&erand%:
Table ;4Re9+ired +nordered-$ignaling #redicate$ and negation$
0
Bnordered-signaling predicate Bnordered-signaling negation
0rue relations +ames 0rue relations +ames
GT co#&areGreater
f
1c @T ?A co#&areSignalingAotGreater
AOT=f>
GT 1c co#&areGreater1()al
f T
]
@T ?A co#&areSignaling@e%%?nordered
AOT=fT>
@T co#&are@e%%
\
1c GT ?A co#&areSignalingAot@le%%
AOT=\>
@T 1c co#&are@e%%1()al
\ T
Z
GT ?A co#&areSignalingGreater?nordered
AOT=\T>
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 62
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
T"e )nordered()iet &redicate% in Table 10, intended for )%e b' &rogra#% .ritten to ta-e into acco)nt t"e
&o%%ibilit' of AaA o&erand%, do not %ignal an e/ce&tion on ()iet AaA o&erand%:
Table !04Re9+ired +nordered-9+iet #redicate$ and negation$
0
Bnordered-)uiet predicate Bnordered-)uiet negation
0rue relations +ames 0rue relations +ames
GT co#&arec)ietGreater
h\T
i%Greater
1c @T ?A co#&arec)ietAotGreater
g\T
AOT=h\T>
GT 1c co#&arec)ietGreater1()al
h\
i%Greater1()al
@T ?A co#&arec)iet@e%%?nordered
g\
AOT=h\>
@T co#&arec)iet@e%%
hfT
i%@e%%
1c GT ?A co#&arec)ietAot@e%%
gfT
AOT=hfT>
@T 1c co#&arec)iet@e%%1()al
hf
i%@e%%1()al
GT ?A co#&arec)ietGreater?nordered
gf
AOT=hf>
?A co#&are?nordered
g
i%?nordered
@T 1c GT co#&areOrdered
\Tf
AOT=g>
T"ere are t.o .a'% to .rite t"e logical negation of a &redicate, one )%ing AOT e/&licitl' and t"e ot"er
re+er%ing t"e relational o&erator. T")% in &rogra#% .ritten .it"o)t con%idering t"e &o%%ibilit' of a AaA
o&erand, t"e logical negation of t"e )nordered%ignaling &redicate =i \ C> i% *)%t t"e )nordered%ignaling
&redicate AOT=i \ C>Q t"e )nordered()iet re+er%ed &redicate =i gfT C> i% different in t"at it doe% not %ignal
an in+alid o&eration e/ce&tion ."en i and C are unor(ere(. 0n contra%t, t"e logical negation of =i T C> #a'
be .ritten eit"er AOT=i T C> or =i g\f C>Q in t"i% ca%e bot" e/&re%%ion% are f)nctionall' e()i+alent to =i hT
C>.
7"!2 Detail$ of con-er$ion bet(een internal floating-#oint and e0ternal character
$e9+ence$
7"!2"0

T"i% :la)%e %&ecifie% con+er%ion% bet.een internal for#at% and e/ternal c"aracter %e()ence for#at%.
:on+er%ion% bet.een internal for#at% of different radice% are correctl' ro)nded and %et e/ce&tion% correctl'
a% de%cribed in $.4.2.
0#&le#entation% %"all &ro+ide con+er%ion% bet.een eac" %)&&orted internal binar' for#at and e/ternal
deci#al c"aracter %e()ence% %)c" t"at, )nder ro)ndTie%To1+en, con+er%ion fro# t"e internal for#at to
e/ternal deci#al c"aracter %e()ence and bac- reco+er% t"e original floating&oint re&re%entation, e/ce&t t"at a
%ignaling AaA #a' be con+erted to a ()iet AaA. See $.12.1 and $.12.6 for detail%.
0#&le#entation% %"all &ro+ide e/act con+er%ion% fro# eac" %)&&orted internal deci#al for#at to e/ternal
deci#al c"aracter %e()ence%, and %"all &ro+ide con+er%ion% bac- t"at reco+er t"e original floating&oint
re&re%entation, e/ce&t t"at a %ignaling AaA #a' be con+erted to a ()iet AaA. See $.12.1 and $.12.6 for
detail%.
0#&le#entation% %"all &ro+ide e/act con+er%ion% fro# eac" %)&&orted internal binar' for#at to e/ternal
c"aracter %e()ence% re&re%enting n)#ber% .it" "e/adeci#al digit%, and %"all &ro+ide con+er%ion% bac- t"at
reco+er t"e original floating&oint re&re%entation, e/ce&t t"at a %ignaling AaA #a' be con+erted to a ()iet
AaA. See $.12.1 and $.12.2 for detail%.
T"i% cla)%e &ri#aril' di%c)%%e% con+er%ion% d)ring &rogra# e/ec)tionQ t"ere i% one %&ecial con%ideration
a&&licable to &rogra# tran%lation %e&arate fro# &rogra# e/ec)tion: tran%lationti#e con+er%ion of con%tant%
in &rogra# te/t fro# e/ternal c"aracter %e()ence% to internal for#at%, in t"e ab%ence of ot"er %&ecification in
t"e &rogra# te/t, %"all )%e t"i% %tandardM% defa)lt ro)nding direction and lang)agedefined e/ce&tion "andling.
!age 40 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
An i#&le#entation #ig"t &ro+ide #ean%, to &er#it con%tant% to be tran%lated at e/ec)tion ti#e .it" t"e
#ode% in effect at e/ec)tion ti#e and e/ce&tion% generated at e/ec)tion ti#e.
0%%)e% of c"aracter code% =AS:00, ?nicode, etc.> are lang)agedefined.
7"!2"! /0ternal character $e9+ence$ re#re$enting <ero$, infinitie$, and 6a6$
7"!2"!"0
T"e con+er%ion% =de%cribed in $.12> fro# internal for#at% to e/ternal c"aracter %e()ence% and bac- t"at
reco+er t"e original floating&oint re&re%entation, reco+er Hero%, infinitie%, and ()iet AaA%, a% .ell a% nonHero
finite n)#ber%. 0n &artic)lar, %ign% of Hero% and infinitie% are &re%er+ed.
:on+er%ion of an infinit' in internal for#at to an e/ternal c"aracter %e()ence %"all &rod)ce a lang)age
defined one of OinfP or Oinfinit'P or a %e()ence t"at i% e()i+alent e/ce&t for ca%e =e.g., O0nfinit'P or O0AFP>,
.it" a &receding #in)% %ign if t"e in&)t i% negati+e. F"et"er t"e con+er%ion &rod)ce% a &receding &l)% %ign if
t"e in&)t i% &o%iti+e i% lang)age defined.
:on+er%ion of e/ternal c"aracter %e()ence% OinfP and Oinfinit'P, regardle%% of ca%e, .it" an o&tional &receding
%ign, to an internal floating&oint for#at %"all &rod)ce an infinit' =.it" t"e %a#e %ign a% t"e in&)t>.
:on+er%ion of a ()iet AaA in internal for#at to an e/ternal c"aracter %e()ence %"all &rod)ce a lang)age
defined one of OnanP or a %e()ence t"at i% e()i+alent e/ce&t for ca%e =e.g., OAaAP>, .it" an o&tional &receding
%ign.
:on+er%ion of a %ignaling AaA in internal for#at to an e/ternal c"aracter %e()ence %"o)ld &rod)ce a
lang)agedefined one of V%nanV or VnanV or a %e()ence t"at i% e()i+alent e/ce&t for ca%e, .it" an o&tional
&receding %ign. 0f t"e con+er%ion of a %ignaling AaA &rod)ce% VnanV or a %e()ence t"at i% e()i+alent e/ce&t
for ca%e, .it" an o&tional &receding %ign, t"en t"e in+alid e/ce&tion %"o)ld be %ignaled.
:on+er%ion of e/ternal c"aracter %e()ence% OnanP, regardle%% of ca%e, .it" an o&tional &receding %ign, to an
internal floating&oint for#at %"all &rod)ce a ()iet AaA.
:on+er%ion of an e/ternal c"aracter %e()ence V%nanV, regardle%% of ca%e, .it" an o&tional &receding %ign, to an
internal for#at %"o)ld eit"er &rod)ce a %ignaling AaA or el%e &rod)ce a ()iet AaA and %ignal t"e in+alid
e/ce&tion.
@ang)age% %"o)ld &ro+ide an o&tional con+er%ion of AaA% in internal for#at to e/ternal c"aracter %e()ence%
t"at a&&end% to t"e ba%ic AaA c"aracter %e()ence% a %)ffi/ t"at can re&re%ent t"e AaA &a'load =%ee B.2>. T"e
for# and inter&retation of t"e &a'load %)ffi/ i% lang)age defined. T"e lang)age %"o)ld re()ire t"at an' %)c"
o&tional o)t&)t %e()ence% be recogniHed a% in&)t in con+er%ion of e/ternal c"aracter %e()ence% to internal
for#at%.
7"!2"2 /0ternal he0adecimal character $e9+ence$ re#re$enting finite n+mber$
7"!2"2"0
0#&le#entation% %)&&orting binar' for#at% %"all &ro+ide con+er%ion% bet.een all %)&&orted internal binar'
for#at% and e/ternal "e/adeci#al c"aracter %e()ence%. 1/ternal "e/adeci#al c"aracter %e()ence% for finite
n)#ber% are of t"e for# %&ecified b' :22 %)bcla)%e%:
6.4.4.2 floating con%tant%,
20.1.6 %trtod,
$.12.6.2 f%canf =a, e, f, g>, and
$.12.6.1 f&rintf =a, A>.
T"e O0/P #a' be o#itted in conte/t% ."ere t"e onl' c"aracter %e()ence data i% "e/adeci#al. F"en
con+erting to "e/adeci#al c"aracter %e()ence% in t"e ab%ence of an e/&licit &reci%ion %&ecification, eno)g"
"e/adeci#al c"aracter% %"all be )%ed to re&re%ent t"e binar' floating&oint n)#ber e/actl'. :on+er%ion% to
"e/adeci#al c"aracter %e()ence% .it" an e/&licit &reci%ion %&ecification, and con+er%ion% fro# "e/adeci#al
c"aracter %e()ence% to internal binar' for#at%, are correctl' ro)nded according to t"e &re+ailing binar'
ro)nding direction #ode.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 41
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
7"!2". /0ternal decimal character $e9+ence$ re#re$enting finite n+mber$
7"!2"."0
T"e con+er%ion &ara#eter + i% %&ecified belo. according to t"e .ide%t internal for#at %)&&orted in a radi/.
For eac" %)&&orted radi/, and i#&le#entation %"all define an integer K ] =+R6> and an integer L =f)rt"er
%&ecified belo.> and %"all &ro+ide con+er%ion bet.een all interc"ange and noninterc"ange for#at% in t"e
radi/ and at lea%t one e/ternal c"aracter %e()ence for#at t"at re&re%ent% all deci#al n)#ber% .it" )& to K
%ignificant digit% and .it" e/&onent% =of 10> in t"e range DNL, LE.
0n internal to deci#al%tring con+er%ion%, if #ore t"an M re%)lt digit% are re()e%ted, t"e in&)t %"all be
con+erted .it" correct ro)nding to M digit%, and e/tra digit% %"all be generated a% Hero%.
0f #ore t"an M digit% are gi+en for deci#al%tring to internal con+er%ion%, t"e re%)lt of t"e con+er%ion %"all be
a% if it .ere carried o)t in t.o %te&%: Fir%t ro)nd t"e gi+en deci#al n)#ber to M deci#al digit%, and t"en
con+ert t"e re%)lting Mdigit n)#ber to t"e target floating&oint for#at, in bot" ca%e% ro)nding correctl'
according to t"e &re+ailing ro)nding #ode.
Table !!4Decimal con-er$ion #arameter m (hen (ide$t $+##orted format i$ ba$ic
0
Iidest !asic format m for !inary formats m for decimal formats
32-bit 9 L
64-bit 17 16
128-bit 36 34
Table 11 %&ecifie% t"e &ara#eter + ."en t"e .ide%t %)&&orted for#at in a &artic)lar radi/ i% ba%ic. F"en t"e
.ide%t i#&le#ented for#at i% not ba%ic:
D 0f t"e .ide%t i#&le#ented binar' for#at can enco#&a%% p %ignificant bit%, t"en + i%
1Rceiling=pUlog10 =2>>
D 0f t"e .ide%t i#&le#ented deci#al for#at can enco#&a%% p %ignificant digit%, t"en + i% p
L %"all be %)fficientl' large to re&re%ent t"e re%)lt of con+erting an' n)#ber in internal for#at to t"e e/ternal
deci#al c"aracter %e()ence for#at .it" )& to K %ignificant digit%.
0#&le#entation% %"o)ld &ro+ide ot"er deci#al c"aracter %e()ence for#at% a% .ell. All con+er%ion% to and
fro# deci#al c"aracter %e()ence for#at%, .it"in t"e con+er%ion &ara#eter li#it% abo+e, are correctl' ro)nded
according to t"e &re+ailing ro)nding direction #ode. For con+er%ion% bet.een binar' for#at% and deci#al
c"aracter %e()ence%, t"e ine/act e/ce&tion %"all be %ignaled correctl' for con+er%ion% of no #ore t"an M
digit%.
For internal to deci#al%tring con+er%ion%, t"e ine/act bit %"all be %et correctl'.
For deci#al%tring to internal con+er%ion%, if #ore t"an M digit% .ere gi+en, and an' of t"o%e e/tra digit% .ere
nonHero, t"e ine/act bit %"all be %et.
T"e table entrie% for + are t"e n)#ber of %ignificant digit% to be &rod)ced ."en con+erting internal binar' to
deci#al c"aracter %e()ence%, ."en no &reci%ion i% %&ecified b' t"e &rogra# or t"e lang)age.
A% a con%e()ence of t"e foregoing, con+er%ion% %"all be #onotonic: increa%ing t"e +al)e of an internal
floating&oint n)#ber %"all not decrea%e it% +al)e after con+er%ion to an e/ternal c"aracter %e()ence, and
increa%ing t"e +al)e of a e/ternal c"aracter %e()ence %"all not decrea%e it% +al)e after con+er%ion to an
internal floating&oint n)#ber.
F"en t"e de%tination i% an e/ternal c"aracter %e()ence, lang)age %&ecification% locate it% lea%t %ignificant
digit for &)r&o%e% of ro)nding. T"e re%)lt for#atM% +al)e% are t"e n)#ber% re&re%entable .it"in t"at lang)age
%&ecification. T"e n)#ber of %ignificant digit% i% deter#ined b' t"at %&ecification, and in t"e ca%e of fi/ed
&oint con+er%ion b' t"e %o)rce +al)e a% .ell.
0f e/ternal to internal con+er%ion o+er7)nderflo.%, t"e re%&on%e i% a% %&ecified in :la)%e 2. O+er7)nderflo.
enco)ntered d)ring internal to e/ternal con+er%ion %"o)ld be indicated to t"e )%er b' a&&ro&riate c"aracter
%e()ence%.
!age 42 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
:" *nfinit', 6a6$, and $ign bit
:"0
:"! *nfinit' arithmetic
0nfinit' arit"#etic %"all be con%tr)ed a% t"e li#iting ca%e of real arit"#etic .it" o&erand% of arbitraril' large
#agnit)de, ."en %)c" a li#it e/i%t%. 0nfinitie% %"all be inter&reted in t"e affine %en%e, t"at i%, NY \ =e+er'
finite n)#ber> \ RY.
O&eration% on infinite o&erand% are )%)all' e/act and t"erefore %ignal no e/ce&tion%. T"e e/ce&tion% t"at do
&ertain to infinitie% are %ignaled onl' ."en:
D N i% an in+alid o&erand =%ee 2.2>,
D N i% created fro# finite o&erand% b' o+erflo. =%ee 2.4> or di+i%ion b' Hero =%ee 2.6>,
D re#ainder=%)bnor#al, Y> %ignal% )nderflo.,
D ne/tAfter=/, Y> %ignal% )nderflo. and ine/act if t"e re%)lt .o)ld be %)bnor#al,
D ne/tAfter=#a/ nor#al, Y> %ignal% o+erflo. and ine/act if t"e re%)lt .o)ld be infinite.
:"2 O#eration$ (ith 6a6$
:"2"0
T.o different -ind% of AaA, %ignaling and ()iet, %"all be %)&&orted in all o&eration%. Signaling AaA% afford
re&re%entation% for )ninitialiHed +ariable% and arit"#eticli-e en"ance#ent% =%)c" a% co#&le/affine infinitie%
or e/tre#el' .ide range> t"at are not t"e %)b*ect of t"e %tandard. c)iet AaA% %"o)ld, b' #ean% left to t"e
i#&le#enterM% di%cretion, afford retro%&ecti+e diagno%tic infor#ation in"erited fro# in+alid or )na+ailable
data and re%)lt%. To facilitate &ro&agation of diagno%tic infor#ation contained in AaA%, a% #)c" of t"at
infor#ation a% &o%%ible %"o)ld be &re%er+ed in AaA re%)lt% of co#&)tational o&eration%.
Signaling AaA% %"all be re%er+ed o&erand% t"at %ignal t"e in+alid o&eration e/ce&tion =%ee 2.1> for e+er'
generalco#&)tational and %ignalingco#&)tational o&eration.
Under default exception handling, any operation signaling an invalid exception for which a floating-point
result is to be delivered, shall deliver a quiet NaN.
1+er' generalco#&)tational and ()ietco#&)tational o&eration in+ol+ing one or #ore in&)t AaA%, none of
t"e# %ignaling, %"all %ignal no e/ce&tion, e/ce&t fusedMultiplyAdd (see 9.2) . For an o&eration .it" ()iet
AaA in&)t% ot"er t"an #a/ and #in o&eration%, if a floating&oint re%)lt i% to be deli+ered, t"e re%)lt %"all be a
()iet AaA, ."ic" %"o)ld be one of t"e in&)t AaA%. 0f t"e trailing %ignificand field of a deci#al in&)t AaA i%
canonical t"en t"e bit &attern of t"at field %"all be &re%er+ed if t"at AaA i% c"o%en a% t"e re%)lt AaA. Aote t"at
for#at con+er%ion%, incl)ding con+er%ion% bet.een internal for#at% and e/ternal re&re%entation% a% c"aracter
%e()ence%, #ig"t be )nable to deli+er t"e %a#e AaA. c)iet AaA% %ignal e/ce&tion% on %o#e o&eration% t"at
do not deli+er a floating&oint re%)ltQ t"e%e o&eration%, na#el' co#&ari%on and con+er%ion to a for#at t"at "a%
no AaA%, are di%c)%%ed in $.4, $.6, and 2.1.
:"2"! 6a6 encoding$ in binar' format$
:"2"!"0
T"i% cla)%e f)rt"er %&ecifie% t"e encoding% of AaA% a% bit %tring% ."en t"e' are t"e re%)lt% of o&eration%.
F"en encoded, all AaA% "a+e a %ign bit and a &attern of bit% nece%%ar' to identif' t"e encoding a% a AaA and
."ic" deter#ine% it% -ind =%AaA +%. (AaA>. T"e re#aining bit%, ."ic" are in t"e trailing field, encode t"e
&a'load, ."ic" #ig"t be diagno%tic infor#ation =%ee B.2>.
All binar' AaA bit%tring% "a+e all t"e bit% of t"e bia%ed e/&onent field 1 %et to 1 =%ee 5.4>. A ()iet AaA
bit%tring %"o)ld be encoded .it" t"e fir%t bit =d1> of t"e trailing %ignificand field T being 1. A %ignaling AaA
bit%tring %"o)ld be encoded .it" t"e fir%t bit of t"e trailing %ignificand field being 0. 0f t"e fir%t bit of t"e
trailing %ignificand i% 0, %o#e ot"er bit of t"e trailing %ignificand field #)%t be nonHero to di%ting)i%" t"e
AaA fro# infinit'.
0n t"e &referred encoding, a %ignaling AaA %"o)ld be ()ieted b' %etting d1 to 1, lea+ing t"e re#aining bit% of T
)nc"anged.
For binar' for#at%, t"e &a'load i% t"e pS2 lea%t %ignificant bit% of t"e trailing %ignificand field.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 46
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
:"2"2 6a6 encoding$ in decimal format$
:"2"2"0
A deci#al %ignaling AaA %"all be ()ieted b' clearing B5 and lea+ing t"e +al)e% of t"e digit% (1 t"ro)g" (p ? 1
of t"e trailing %ignificand )nc"anged =%ee 5.5>.
An' co#&)tational o&eration ."ic" &rod)ce%, &ro&agate%, or ()iet% a deci#al for#at AaA %"all %et t"e bit%
B6 t"ro)g" BwR4 of B to 0, and %"all generate onl' a canonical trailing %ignificand field.
For deci#al for#at%, t"e &a'load i% t"e trailing %ignificand field.
:"2". 6a6 #ro#agation
:"2"."0
An o&eration ."ic" &ro&agate% AaA% and "a% a %ingle AaA a% an in&)t %"o)ld &rod)ce a AaA .it" t"e
&a'load of t"e in&)t AaA.
0f t.o or #ore in&)t% are AaA, t"en t"e &a'load of t"e re%)lting AaA %"o)ld be identical to t"e &a'load of one
of t"e in&)t AaA%. T"i% %tandard doe% not %&ecif' ."ic" of t"e in&)t AaA% .ill &ro+ide t"e &a'load.
:on+er%ion of a ()iet AaA fro# a narro.er for#at to a .ider for#at in t"e %a#e radi/, and t"en bac- to t"e
%a#e narro.er for#at, %"o)ld not c"ange t"e ()iet AaA &a'load in an' .a'.
:on+er%ion of a ()iet AaA to a floating&oint for#at of t"e %a#e or a different radi/ t"at doe% not allo. t"e
&a'load to be &re%er+ed, %"o)ld ret)rn a ()iet AaA t"at %"o)ld &ro+ide %o#e lang)agedefined diagno%tic
infor#ation.
T"ere %"o)ld be #ean% to read and .rite AaA &a'load% fro# and to e/ternal c"aracter %e()ence% =%ee $.12.1>.
:". The $ign bit
:"."0
F"en eit"er an in&)t or re%)lt i% AaA, t"i% %tandard doe% not inter&ret t"e %ign of a AaA. Aote "o.e+er t"at
o&eration% on bit%tring% N co&', negate, ab%, co&'Sign N %&ecif' t"e %ign bit of a AaA re%)lt, %o#eti#e% ba%ed
)&on t"e %ign bit of a AaA o&erand. T"e logical &redicate totalOrder i% al%o affected b' t"e %ign bit of a AaA
o&erand. For all ot"er o&eration%, t"i% %tandard doe% not %&ecif' t"e %ign bit of a AaA re%)lt, e+en ."en t"ere
i% onl' one in&)t AaA, or ."en t"e AaA i% &rod)ced fro# an in+alid o&eration.
F"en neit"er t"e in&)t% nor re%)lt are AaA, t"e %ign of a &rod)ct or ()otient i% t"e e/cl)%i+e OR of t"e
o&erand%M %ign%Q t"e %ign of a %)#, or of a difference =?y regarded a% a %)# =R=Ny>, differ% fro# at #o%t one of
t"e addend%M %ign%Q and t"e %ign of t"e re%)lt of ro)ndTo0ntegral and ro)ndTo0ntegral1/act =%ee $.6.1> i% t"e
%ign of t"e o&erand. T"e%e r)le% %"all a&&l' e+en ."en o&erand% or re%)lt% are Hero or infinite.
F"en t"e %)# of t.o o&erand% .it" o&&o%ite %ign% =or t"e difference of t.o o&erand% .it" li-e %ign%> i%
e/actl' Hero, t"e %ign of t"at %)# =or difference> %"all be R in all ro)nding direction #ode% e/ce&t
roundTowardNegative; in t"at #ode, t"e %ign of an e/act Hero %)# =or difference> %"all be N. 4o.e+er, =R= T
=?=N=> retain% t"e %a#e %ign a% = e+en ."en = i% Hero.
F"en =ab>R* .o)ld +ani%" in e/act arit"#etic, t"e %ign of f)%edM)lti&l'Add=a, b, *> %"all be deter#ined b'
t"e r)le% abo+e for a %)# of o&erand%.
1/ce&t t"at %()areRoot=N0> %"all be N0, e+er' +alid %()areRoot %"all "a+e a &o%iti+e %ign.
!age 44 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
;" Defa+lt e0ce#tion handling
;"0
;"! O-er-ie(% e0ce#tion$ and flag$
;"!"0
T"ere are fi+e t'&e% of e/ce&tion% t"at %"all be %ignaled. T"i% cla)%e %&ecifie% defa)lt non%to& e/ce&tion
"andling, ."ic" )%)all' entail% rai%ing a %tat)% flag, deli+ering a defa)lt re%)lt, and contin)ing e/ec)tion. A
lang)age #ig"t define #ode% for alternate e/ce&tion "andling and #ean% for &rogra##er% to in+o-e t"e#.
For eac" t'&e of e/ce&tion t"e i#&le#entation %"all &ro+ide a %tat)% flag t"at %"all be rai%ed ."en t"e
corre%&onding e/ce&tion i% %ignaled. 0t %"all be lo.ered onl' at t"e )%erM% re()e%t. T"e )%er %"all be able to
te%t and to alter t"e %tat)% flag% indi+id)all', and %"o)ld f)rt"er be able to %a+e and re%tore all fi+e at one ti#e.
=See $.$.4 and $.$.5>
A &rogra# t"at doe% not in"erit %tat)% flag% fro# anot"er %o)rce, begin% e/ec)tion .it" all %tat)% flag%
lo.ered.
@ang)age% %"o)ld %&ecif' defa)lt% in t"e ab%ence of an' e/&licit &rogra# %&ecification, go+erning
D ."et"er an' &artic)lar flag e/i%t% =in t"e %en%e of being te%table b' non&rogra##atic #ean% %)c" a%
deb)gger%> o)t%ide of %co&e% in ."ic" a &rogra# e/&licitl' %et% or te%t% t"at flag
D ."en flag% "a+e %co&e greater t"an .it"in an in+o-ed f)nction, ."et"er and ."en an a%'nc"rono)%
e+ent, %)c" a% a rai%ing or lo.ering it in anot"er t"read or %ignal "andler, affect% t"e flag te%ted
.it"in t"at in+o-ed f)nction
D ."en flag% "a+e %co&e greater t"an .it"in an in+o-ed f)nction, ."et"er a flagM% %tate can be
deter#ined b' non&rogra##atic #ean% =%)c" a% a deb)gger> .it"in t"at in+o-ed f)nction
D ."et"er flag% rai%ed in in+o-ed %)bf)nction% %et flag% in in+o-ing f)nction%
D ."et"er flag% rai%ed in in+o-ing f)nction% %et flag% in in+o-ed %)bf)nction%
D ."et"er to allo., and if %o t"e #ean%, to declare flag% to be &er%i%tent in t"e ab%ence of an' e/&licit
&rogra# %tate#ent ot"er.i%e:
D t"e flag% %tanding at t"e beginning of e/ec)tion of a &artic)lar f)nction are in"erited fro# an
o)ter en+iron#ent, t'&icall' an in+o-ing f)nction
D on ret)rn fro# or ter#ination of an in+o-ed %)bf)nction, t"e flag% %tanding in an in+o-ing
f)nction are t"e flag% t"at .ere %tanding in t"e %)bf)nction at t"e ti#e of ret)rn or ter#ination
An in+ocation of t"e %ignale/ce&tion o&eration of $.6.2, #a' %ignal an' co#bination of e/ce&tion%. For an
in+ocation of an' ot"er o&eration re()ired b' t"i% %tandard, at #o%t t.o e/ce&tion% #ig"t be %ignaled, in *)%t
t"e%e co#bination%: o+erflo. follo.ed b' ine/act, and )nderflo. follo.ed b' ine/act.
T"e ine/act e/ce&tion i% %ignaled if t"e o+erflo. e/ce&tion recei+e% defa)lt "andling, and #ig"t be %ignaled if
t"e )nderflo. e/ce&tion recei+e% defa)lt "andling =%ee 2.5>.
0n general, ."en an o&eration %ignal% #ore t"an one e/ce&tion, none of ."ic" "a+e alternate e/ce&tion
"andling enabled, eac" %ignaled e/ce&tion .ill recei+e it% defa)lt "andling.
F"en an o&eration %ignal% #ore t"an one e/ce&tion, %o#e or all of ."ic" "a+e alternate e/ce&tion "andling
enabled, alternate e/ce&tion "andling .ill be in+o-ed for t"e #o%t i#&ortant e/ce&tion, and lang)age% define
."et"er ot"er %ignaled e/ce&tion% recei+e defa)lt "andling, alternate "andling, or are ignored. 1/ce&tion%
are li%ted in t"i% cla)%e in order of decrea%ing i#&ortance =in+alid #o%t i#&ortant, ine/act lea%t i#&ortant>.
For t"e co#&)tational o&eration% defined in t"i% %tandard, e/ce&tion% are defined belo. to be %ignaled if and
onl' if certain condition% ari%e. T"at i% not #eant to i#&l' ."et"er t"o%e e/ce&tion% are %ignaled b'
o&eration% not %&ecified b' t"i% %tandard %)c" a% co#&le/ arit"#etic or ele#entar' tran%cendental f)nction%.
T"o%e and ot"er o&eration%, not %&ecified b' t"i% %tandard, %"o)ld %ignal t"o%e e/ce&tion% according to t"e
definition% belo. for %tandard o&eration%, b)t t"at #a' not al.a'% be econo#ical. Standard e/ce&tion% for
non%tandard f)nction% are lang)agedefined.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 45
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
;"2 *n-alid o#eration
;"2"0
T"e in+alid o&eration e/ce&tion i% %ignaled if and onl' if t"ere i% no )%ef)ll' definable re%)lt. 0n t"e%e ca%e%
t"e o&erand% are in+alid for t"e o&eration to be &erfor#ed.
For o&eration% &rod)cing re%)lt% in floating&oint for#at, t"e defa)lt re%)lt of an in+alid e/ce&tion o&eration
%"all be a ()iet AaA t"at %"o)ld &ro+ide %o#e diagno%tic infor#ation =%ee B.2>. S)c" in+alid e/ce&tion
o&eration% in t"i% %tandard are:
a> an' generalco#&)tational or %ignalingco#&)tational o&eration on a %ignaling AaA =%ee B.2>Q
b> #)lti&lication: #)lti&lication=0, Y> or #)lti&lication=Y, 0>Q
c> f)%edM)lti&l'Add: f)%edM)lti&l'Add=0, Y, *> or f)%edM)lti&l'Add=Y, 0, *> )nle%% * i% a ()iet AaAQ
if * i% a ()iet AaA t"en it i% i#&le#entation defined ."et"er t"e in+alid o&eration e/ce&tion i%
%ignaledQ
d> addition or %)btraction or f)%edM)lti&l'Add: #agnit)de %)btraction of infinitie%, %)c" a%:
addition=RY, NY>Q
e> di+i%ion: di+i%ion=0, 0> or di+i%ion=Y, Y>Q
f> re#ainder: re#ainder==,y>, ."ere y i% Hero or = i% infinite and neit"er i% AaAQ
g> %()areRoot if t"e o&erand i% le%% t"an HeroQ
"> ()antiHe ."en t"e re%)lt doe% not fit in t"e de%tination for#at or ."en one o&erand i% finite and t"e
ot"er i% infinite.
For o&eration% &rod)cing no re%)lt in floating&oint for#at, t"e in+alid e/ce&tion o&eration% are:
i> con+er%ion of an internal floating&oint n)#ber to an integer for#at, ."en t"e %o)rce i% AaA,
infinit', or a +al)e ."ic" .o)ld con+ert to an integer o)t%ide t"e range of t"e re%)lt for#at )nder t"e
&re+ailing ro)nding #ode.
*> co#&ari%on b' .a' of )nordered%ignaling &redicate% li%ted in Table 2, ."en t"e o&erand% are
unor(ere(Q
-> log,=AaA>, log,=Y>, and log,=0> ."en &og3For+at i% an integer for#at =%ee $.6.6> .
;". Di-i$ion b' <ero
;"."0
T"e di+ide,'Jero e/ce&tion %"all be %ignaled if and onl' if an e/act infinite re%)lt i% defined for an o&eration
on finite o&erand%. 0n &artic)lar, t"e di+i%ion b' Hero e/ce&tion %"all be %ignaled if t"e di+i%or i% Hero and t"e
di+idend i% a finite nonHero n)#ber. T"e defa)lt re%)lt %"all be a correctl' %igned Y =%ee B.6>.
F"en &og3For+at i% a floating&oint for#at, log,=0> i% NY and %ignal% t"e di+i%ion b' Hero e/ce&tion.
;"4 O-erflo(
;"4"0
T"e o+erflo. e/ce&tion %"all be %ignaled if and onl' if t"e de%tination for#atM% large%t finite n)#ber i%
e/ceeded in #agnit)de b' ."at .o)ld "a+e been t"e ro)nded floating&oint re%)lt =:la)%e 6> .ere t"e
e/&onent range )nbo)nded. T"e defa)lt re%)lt %"all be deter#ined b' t"e ro)nding direction #ode and t"e
%ign of t"e inter#ediate re%)lt a% follo.%:
a> ro)ndTie%To1+en and ro)ndTie%ToA.a' carrie%
all o+erflo.% to Y .it" t"e %ign of t"e inter#ediate re%)lt
b> ro)ndTo.ardJero carrie%
all o+erflo.% to t"e for#atM% large%t finite n)#ber .it" t"e %ign of t"e inter#ediate re%)lt
c) roundTowardNegative carrie%
&o%iti+e o+erflo.% to t"e for#atM% large%t finite n)#ber, and carrie% negati+e o+erflo.% to NY
d) roundTowardPositive carrie%
negati+e o+erflo.% to t"e for#atM% #o%t negati+e finite n)#ber, and carrie%
&o%iti+e o+erflo.% to RY
!age 46 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
4o.e+er ne/tAfter==,'> %ignal% o+erflo. and ine/act if and onl' if ne/tAfter i% infinite and differ% fro# t"e
finite n)#ber =.
;" =nderflo(
;""0
T"e )nderflo. e/ce&tion i% %ignaled ."en a tin' nonHero re%)lt .o)ld be created %trictl' bet.een _b
e+in
. T"e
i#&le#enter #a' c"oo%e "o. tinine%% i% detected, b)t %"all detect tinine%% in t"e %a#e .a' for all o&eration%
of a gi+en radi/ =in t"e ca%e of a con+er%ion o&eration, t"e radi/ fro# ."ic" t"e ro)nding #ode i% ta-en>.
Tinine%% #a' be detected eit"er:
a> A,ter roun(ing N ."en a nonHero re%)lt co#&)ted a% t"o)g" t"e e/&onent range .ere )nbo)nded
.o)ld lie %trictl' bet.een _ b
e+in
b> 3e,ore roun(ing N ."en a nonHero re%)lt co#&)ted a% t"o)g" bot" t"e e/&onent range and t"e
&reci%ion .ere )nbo)nded .o)ld lie %trictl' bet.een _ b
e+in
.
T"e #et"od for detecting tinine%% doe% not affect t"e defa)lt ro)nded re%)lt deli+ered ."ic" #ig"t be Hero,
%)bnor#al, or _ b
e+in
.
@o%% of acc)rac' %"all be detected a% an ine/act re%)lt N ."en t"e deli+ered re%)lt differ% fro# ."at .o)ld
"a+e been co#&)ted .ere bot" e/&onent range and &reci%ion )nbo)nded. =T"i% i% t"e condition called ine/act
in 2.6>.
T"e defa)lt e/ce&tion "andling for )nderflo. i% to deli+er a ro)nded re%)lt, rai%e t"e )nderflo. flag, and
%ignal t"e ine/act e/ce&tion, if and onl' if bot" tinine%% and lo%% of acc)rac' "a+e been detectedQ if no lo%% of
acc)rac' occ)r%, no flag i% rai%ed.
4o.e+er ne/tAfter==,y> %ignal% )nderflo. and ine/act if and onl' if t"e re%)lt i% %trictl' bet.een _b
e+in
and
differ% fro# =.
;"6 *ne0act
;"6"0
0f t"e ro)nded re%)lt of an o&eration i% not e/act or if it o+erflo.% .it" defa)lt "andling t"en t"e ine/act
e/ce&tion %"all be %ignaled. T"e ro)nded or o+erflo.ed re%)lt %"all be deli+ered to t"e de%tination.
ne/tAfter==,y> %ignal% ine/act if and onl' if ne/tAfter al%o %ignal% o+erflo. or )nderflo..
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 4$
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
Anne0e$
0
0
0
0
0
Anne0 A
>informati-e?
Anne0 A >informati-e? 3ibliogra#h'
T"e follo.ing doc)#ent% #a' be "el&f)l to t"e reader:
?nited State% !atent 6,46$,$15, :o.li%"a., A)g)%t 20, 2002: Deci#al to binar' coder7decoder. =T"e )%e
of t"i% &atent i% ro'alt'free for an'one i#&le#enting t"i% %tandard> DAote to t"e 0111 editor% N t"ere i% %o#e
a#o)nt of conf)%ion a#ong t"e $54r co##ittee on t"e i%%)e ."et"er or not a =non &eerre+ie.ed> &atent
belong% in t"e bibliogra&"' of t"i% doc)#ent. Fe are told t"at t"e 0111 .i%"e% to "a+e t"e &atent referenced
in t"i% doc)#ent for t"e &)r&o%e% of noting t"at it i% ro'alt'free to i#&le#enter%, b)t "a+e %een no official
co##)nication to t"at effect.E
01: 60552:12B2, ,inar' floating&oint arit"#etic for #icro&roce%%or %'%te#% =&re+io)%l' de%ignated 01:
552:12B2>
AAS070111 Std $54N12B5, 0111 Standard for ,inar' Floating!oint Arit"#etic.
0SO701: 2B22, Second edition 12221201, !rogra##ing lang)age%3:
Den%el'!ac-ed Deci#al 1ncoding, Mic"ael F. :o.li%"a., 011 !roceeding% :o#&)ter% and Digital
Tec"ni()e%, 8ol. 142 j6, 0SSA 165026B$, &&102104, 011, @ondon, Ma' 2002.
Deci#al Floating!oint: Algorit"# for :o#&)ter%, Mic"ael F. :o.li%"a., !roceeding% of t"e 16t" 0111
S'#&o%i)# on :o#&)ter Arit"#etic, 0S,A 0$6251B24i, &&104111, 0111, 9)ne 2006.
9a#e% F. De##el and iiao'e @i. Fa%ter n)#erical algorit"#% +ia e/ce&tion "andling. 0111 Tran%action% on
:o#&)ter%, 46=B>:2B6N222, 1224.
Defo)r, OFonction% klk#entaire%: algorit"#% et i#&lk#entation% efficace% &o)r l`arrondi correct en do)ble
&rkci%ionP, !"D t"e%i%, 1cole Aor#ale S)&krie)re de @'on, Se&te#ber 2006.
F. de Dinec"in, :. @oirat, 9.M. M)ller, OA &ro+en correctl' ro)nded logarit"# in do)ble &reci%ionP, Real
A)#ber% and :o#&)ting`6, &&. $1B5, Dag%t)"l, Ger#an' =2004>.
F. de Dinec"in, A. 1r%"o+, A. Ga%t, OTo.ard% t"e &o%t)lti#ate lib#P, !roc. Arit" 1$, && 2BB225, 0111
:o#&)ter Societ', 2005.
A. 4ig"a#, Acc)rac' and Stabilit' of A)#erical Algorit"#%, Societ' for 0nd)%trial and A&&lied
Mat"e#atic% =S0AM>, 1226.
F. Ka"an, V,ranc" :)t% for :o#&le/ 1le#entar' F)nction%, or M)c" Ado Abo)t Aot"ingM% Sign ,itV, T"e
State of t"e Art in A)#erical Anal'%i%, =ed%. 0%erle% and !o.ell>, :larendon !re%%, O/ford, 12B$.
@efl+re, VAe. re%)lt% on t"e di%tance bet.een a %eg#ent and Jm2. A&&lication to t"e e/act ro)ndingV, !roc.
Arit" 1$, && 6B$5, 0111 :o#&)ter Societ', 2005.
8. @efl+re, 9.M. M)ller, OFor%t ca%e% for correct ro)nding of t"e ele#entar' f)nction% in do)ble &reci%ionP,
!roc. Arit" 15, &&. 11111B, 0111 :o#&)ter Societ', 2001.
9.M. M)ller, O1le#entar' F)nction%: Algorit"#% and 0#&le#entationP, %econd edition, ,ir-"ae)%er =2005>,
:"a&ter 10.
D. Ste"lk, 8,. @efl+re, and !. Ji##er#ann, OSearc"ing .or%t ca%e% of a one+ariable f)nctionP, 0111
Tran%action% on :o#&)ter%, 54=6>: 640646, Marc" 2005.
!age 4B :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
0
0
0
0
0
Anne0 3
>informati-e?
Anne0 3>informati-e? /0#re$$ion e-al+ation
00 3"! O-er-ie(
1+er' o&eration "a% an i#&licit or e/&licit de%tination. F"en a +ariable i% a final de%tination, a% in con+er%ion
to a +ariable, t"e for#at of t"at +ariable go+ern% it% ro)nding. T"e for#at of an anon'#o)% de%tination i%
defined b' lang)age e/&re%%ion e+al)ation r)le%.
So#e lang)age% i#&licitl' con+ert o&erand% of %tandard floating&oint o&eration% to a co##on for#at.
T'&icall', o&erand% are &ro#oted to t"e .ide%t for#at of t"e o&erand% or a Fidento for#at =%ee Anne/ :>.
4o.e+er, if t"e co##on for#at i% not a %)&er%et of t"e o&erand for#at%, t"en t"e con+er%ion #ig"t not
&re%er+e t"e +al)e% of t"e o&erand%. 1/a#&le% incl)de:
L con+erting a fi/ed&oint or integer o&erand to a floating&oint for#at .it" le%% &reci%ion
L con+erting a floating&oint o&erand fro# one radi/ to anot"er
L con+erting a floating&oint o&erand to a for#at .it" t"e %a#e radi/ b)t .it" le%% range or &reci%ion
@ang)age% %"o)ld di%allo., or &ro+ide .arning% for, #i/edfor#at o&eration% t"at .o)ld ca)%e i#&licit
con+er%ion t"at #ig"t c"ange o&erand +al)e%.
Iidento methods
Anne/ : &re%cribe% Fidento #et"od% for .idening o&eration% in e/&re%%ion%. Fidening, ."ic" %"o)ld be
a+ailable in e+er' i#&le#entation %)&&orting #ore t"an one floating&oint for#at in a radi/, i% &erfor#ed a%
%&ecified b' t"e )%er, and t")% i% not an o&ti#iHation in t"e )%)al %en%e. Fidening occ)r% before o&ti#iHation
i% con%idered.
2eproduci!le results
@ang)age% %"o)ld &ro+ide #ean% for &rogra##er% to %&ecif' re&rod)cible re%)lt%Lre%)lt% t"at are identical
on all &latfor#% %)&&orting t"at lang)age and t"i% %tandard, for o&eration% co#&letel' %&ecified b' t"i%
%tandard.
00 3"2 O#timi<ation
A% &art of %)&&ort for t"i% %tandard, a lang)age %"o)ld re()ire t"at e/ec)tion be"a+ior &re%er+e t"e literal
#eaning of t"e %o)rce code and not c"ange t"e n)#erical re%)lt% or e/ce&tion% %ignaled. 4o.e+er, t"e
lang)age %"o)ld define, and re()ire i#&le#entation% to &ro+ide, #ean% to allo. or di%allo. t"e follo.ing
o&ti#iHation%, %e&aratel' and collecti+el', for a lang)agedefined %'ntactic )nit of t"e &rogra#:
L %'nt"e%i% of a f)%edM)lti&l'Add o&eration fro# a #)lti&lication and an addition
L %'nt"e%i% of a for#atOf o&eration fro# an o&eration and a con+er%ion of t"e re%)lt of t"e o&eration
L )%e of rea%%ociation and .ider inter#ediate% to e+al)ate a %)# red)ction
L )%e of rea%%ociation and .ider inter#ediate% to e+al)ate a &rod)ct red)ction
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 42
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
00 3". A$$ignment$
A%%ign#ent of an e/&re%%ion to a +ariable %"o)ld be i#&le#ented b' f)rt"er ro)nding t"e re%)lt +al)e of t"e
a%%igned e/&re%%ion to t"e .idt" of t"e a%%ignedto +ariable. 0#&le#entation% %"o)ld ne+er )%e an a%%ignedto
+ariableM% .ider &rec)r%or in &lace of t"e a%%ignedto +ariableM% %tored +al)e ."en e+al)ating %)b%e()ent
e/&re%%ion%.
Act)al &ara#eter% to nongeneric f)nction call% are li-e a%%ign#ent%, and are ro)nded to t"e t'&e of t"e for#al
&ara#eter if a declaration i% in %co&e, and are ro)nded to a lang)agedefined t'&e ot"er.i%e. @ang)age% define
r)le% for act)al &ara#eter% to generic f)nction%.
8al)e% to be ret)rned b' f)nction% of declared t'&e% are li-e a%%ign#ent% and %"o)ld be ro)nded to t"e
declared t'&e of t"e f)nction. @ang)age% define r)le% for t'&e% of generic f)nction ret)rn +al)e% according to
t"e f)nction &ara#eter%.
!age 50 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
0
0
0
0
0
Anne0 )
>informati-e?
Anne0 ) >informati-e? @idento method$ for e0#re$$ion e-al+ation
0n t"i% %tandard, a co#&)tational o&eration fir%t &rod)ce% an )nro)nded re%)lt a% an e/act n)#ber of infinite
&reci%ion. T"at )nro)nded re%)lt i% t"en ro)nded to a de%tination for#at. For certain lang)age%&ecified
generic o&eration%, t"at de%tination for#at i% i#&lied b' t"e .idt"% of t"e o&erand% and b' t"e Iidento
method c)rrentl' in effect.
An i#&le#entation %"o)ld &ro+ide a Fidento #et"od for eac" %)&&orted non%torage for#at.
T"e follo.ing Fidento #et"od% di%able and enable .idening of o&eration% in e/&re%%ion% t"at #ig"t be a%
%i#&le a% 4 T = R y or t"at #ig"t in+ol+e %e+eral o&eration% on o&erand% of different for#at%.
L noFidento #et"od: A lang)age %"o)ld define, and re()ire i#&le#entation% to &ro+ide, #ean% for
)%er% to %&ecif' a noFidento #et"od, for a lang)age defined %'ntactic )nit of t"e &rogra#.
De%tination .idt" i% t"e #a/i#)# of t"e o&erand .idt"%: generic o&eration% .it" floating&oint
o&erand% and re%)lt% =of t"e %a#e radi/> ro)nd re%)lt% to t"e .ide%t for#at a#ong t"e o&erand%,
)nle%% t"at for#at i% a %torage for#atQ t"en t"e re%)lt %"o)ld be ro)nded to t"e narro.e%t %)&&orted
ba%ic for#at.
L .identoFor#at #et"od%: A lang)age t"at &ro+ide% addition, %)btraction, #)lti&lication, di+i%ion,
and co#&ari%on a% generic o&erator% %"o)ld define, and re()ire i#&le#entation% to &ro+ide, #ean%
for )%er% to %&ecif' a .identoFor#at #et"od for eac" %)&&orted for#at, e/ce&t %torage for#at%, for a
lang)age defined %'ntactic )nit of t"e &rogra#. .identoFor#at #et"od% affect t"e afore#entioned
o&erator%. F"et"er and ."ic" ot"er generic o&erator% or f)nction% t"e' affect i% lang)age defined.
Table :.1 li%t% o&erator% t"at are %)itable for being affected b' Fidento #et"od%. De%tination .idt"
i% t"e #a/i#)# of t"e .idt" of t"e .identoFor#at and o&erand .idt"%: affected o&eration% .it"
floating&oint o&erand% and re%)lt% =of t"e %a#e radi/> ro)nd re%)lt% to t"e .ide%t for#at a#ong t"e
o&erand% and t"e .identoFor#at. Affected o&eration% =incl)ding co#&ari%on%> do not narro. t"eir
o&erand%, ."ic" #a' be .idened e/&re%%ion%. .identoFor#at affect% onl' e/&re%%ion% in t"e radi/
of for#at.
Fidento #et"od% do not affect t"e .idt" of t"e final ro)nding to an e/&licit de%tination, ."ic" i% al.a'%
ro)nded to t"e declared for#at of t"at de%tination.
Fidento #et"od% do not affect e/&licit for#at con+er%ion% .it"in e/&re%%ion%Q t"e' are al.a'% ro)nded to t"e
for#at %&ecified b' t"e con+er%ion.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 51
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
Table )"!4@idento o#eration$
Hperation
(e'tination addition='our*e1, 'our*e2>
(e'tination su!traction='our*e1, 'our*e2>
(e'tination multiplication='our*e1, 'our*e2>
(e'tination di.ision='our*e1, 'our*e2>
(e'tination s)uare2oot ='our*e1>
(e'tination fused*ultiplyAdd ='our*e1, 'our*e2, 'our*eE>
(e'tination min+um='our*e1, 'our*e2>
(e'tination max+um='our*e1, 'our*e2>
(e'tination min+um*ag='our*e1, 'our*e2>
(e'tination max+um*ag='our*e1, 'our*e2>
boo&ean compare?)ualO'our*e1,'our*e2J
boo&ean compare+ot?)ualO'our*e1,'our*e2J
boo&ean compareFreaterO'our*e1,'our*e2J
boo&ean compareFreater?)ualO'our*e1,'our*e2J
boo&ean compareLessO'our*e1,'our*e2J
boo&ean compareLess?)ualO'our*e1,'our*e2J
boo&ean compareEignaling+otFreaterO'our*e1,'our*e2J
boo&ean compareEignalingLessBnorderedO'our*e1,'our*e2J
boo&ean compareEignaling+otLessO'our*e1,'our*e2J
boo&ean compareEignalingFreaterBnorderedO'our*e1,'our*e2J
boo&ean compareGuietFreaterO'our*e1,'our*e2J
boo&ean compareGuietFreater?)ualO'our*e1,'our*e2J
boo&ean compareGuietLessO'our*e1,'our*e2J
boo&ean compareGuietLess?)ualO'our*e1,'our*e2J
boo&ean compareBnorderedO'our*e1,'our*e2J
boo&ean compareGuiet+otFreater('our*e1,'our*e2J
boo&ean compareGuietLessBnorderedO'our*e1,'our*e2J
boo&ean compareGuiet+otLess('our*e1,'our*e2J
boo&ean compareGuietFreaterBnorderedO'our*e1,'our*e2J
boo&ean compareHrdered('our*e1,'our*e2J
(e'tination f='our*e> for f an' of t"e f)nction% in Table D.1
T"e Fidento #et"od% define t"e .idt" of a generic o&eration to be t"e #a/i#)# of t"e .idt"% of it%
o&erand% and t"e .idt" of t"e .identoFor#at, if an' i% in effect. T"at O#a/i#)#P i#&lie% an ordering a#ong
t"e for#at% of t"e o&erand%Lone #)%t be a %)b%et of t"e ot"er =%ee ,.1>.
!age 52 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
0
0
0
0
0
Anne0 D
>informati-e?
Anne0 D>informati-e? /lementar' tran$cendental f+nction$
Mean% are -no.n b' ."ic" certain ele#entar' tran%cendental f)nction% #a' be co#&)ted correctl' ro)nded,
in all ro)nding direction #ode% L b)t in %o#e ca%e% o+er li#ited do#ain%. 0#&le#entation% %"o)ld &ro+ide
correctl'ro)nded +er%ion% of t"e f)nction% li%ted in Table D.1, for binar'62 for#at if %)&&orted and binar'64
for#at if %)&&orted.
0#&le#entation% %"o)ld al%o &ro+ide fait"f)ll'ro)nded +er%ion% ."en t"e%e are %ignificantl' #ore efficient
t"an correctl'ro)nded. For all ot"er ba%ic for#at%, t"e%e f)nction% %"o)ld be fait"f)ll'ro)nded.
Fait"f)l ro)nding i% defined t")%: let / denote an infinitel' &reci%e n)#ber to be ro)nded according to t"e
&re+ailing ro)nding direction #ode:
L 0n a ro)nding direction #ode to neare%t, if = i% a floating&oint n)#ber, = i% t"e fait"f)ll' ro)nded
re%)lt.
L 0n a ro)nding direction #ode to neare%t, if = i% not a floating&oint n)#ber, eit"er of t"e t.o neare%t
floating&oint n)#ber% brac-eting = i% t"e fait"f)ll' ro)nded re%)lt.
L 0n a directed ro)nding #ode, if = i% a floating&oint n)#ber, eit"er = or t"e ne/t floating&oint
n)#ber in t"e %&ecified direction i% t"e fait"f)ll'ro)nded re%)lt.
L 0n a directed ro)nding #ode, if = i% not a floating&oint n)#ber, eit"er of t"e t.o floating&oint
n)#ber% neare%t = in t"e %&ecified direction i% t"e fait"f)ll' ro)nded re%)lt.
F)rt"er#ore, fait"f)ll'ro)nded re%)lt% %"o)ld &re%er+e i#&ortant &ro&ertie% of t"e )nro)nded and correctl'
ro)nded f)nction%:
L e/actl' re&re%entable re%)lt%,
L #onotonicit',
L %'##etr' in ro)nding direction #ode% to neare%t.
,eca)%e t"e%e f)nction% are tran%cendental, t"e' are al#o%t al.a'% ine/actQ ."en re%)lt% are ine/act b)t no
ot"er e/ce&tion i% %ignaled, lang)age% define ."et"er t"e ine/act e/ce&tion i% %ignaled, not %ignaled, or
indeter#inate, b)t t"e ine/act e/ce&tion %"o)ld not be %ignaled for e/act re%)lt%.
For all f)nction%, %ignaling AaA o&erand% %ignal t"e in+alid e/ce&tion.
For f an' of e/&#1, log1&, %in!i, atan!i, %in, and atan, f=+0> i% +0 and f=-0> i% -0.
@ang)age% %"o)ld define ."ic" ot"er #at"e#atical f)nction% are re()ired or reco##ended to be &ro+ided in
correctl'ro)nded and fait"f)ll'ro)nded +er%ion%.
F"en a lang)age %&ecifie% ele#entar' tran%cendental f)nction%, eac" i#&le#entation %"o)ld doc)#ent t"e
.or%tca%e acc)racie% ac"ie+ed and indicate ."et"er t"e acc)racie% are &ro+en or #ea%)red for a %)b%et of
in&)t%.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 56
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
Table D"!4Standardi<ed tran$cendental f+nction$
Hperation =unction
Correctly-rounded
domain
?xceptions
e/& e
/
DNY, RYE o+erflo.Q )nderflo.
e/&#1 e
/
N1 DNY, RYE o+erflo.Q )nderflo.
%in" %in"==> DNY, RYE overflow
co%" co%"==> DNY, RYE overflow
log
log2
log10
loge=/>
log2=/>
log10=/>
=0, RYE = T 0: di+i%ion b' HeroQ
= \ 0: in+alid
log1& loge=1R/> =N1, RYE = T 1: di+i%ion b' HeroQ
= \ 1: in+alid
%in!i %in=P Q => e#&t' e=e T Y: in+alidQ
)nderflo.
co%!i co%=P Q => e#&t' e=e T Y: in+alid
atan!i atan==>7P e#&t' )nderflo.
%in %in==> DNn, RnE e=e T Y: in+alidQ
)nderflo.
co% co%==> DNn, RnE e=e T Y: in+alid
tan tan==> DNn, RnE e=e T Y: in+alidQ
)nderflo., o+erflo.
a%in a%in==> DN1, R1E e=e f 1: in+alid
aco% aco%==> DN1, R1E e=e f 1: in+alid
atan atan==> DNtan=!2>, Rtan=!2>E
for R=R f tan=!2>, %ee te/t belo.
)nderflo.
So#e f)nction%, %)c" a% co%!i and log, can )nderflo. and7or o+erflo. in an abnor#al for#at .it" a ")ge
&reci%ion and a %#all e/&onent field. T"e%e are not noted in Table D.1 and are not antici&ated to occ)r in
co##on &ractice.
All f)nction% %"o)ld be fait"f)ll' ro)nded o)t%ide t"e correctl'ro)nded do#ain, e/ce&t:
L For atan, !2 i% P 7 2 ro)nded to.ard Hero in t"e for#at of =)
D F"en e/e f tan=!2> in ro)nding direction #ode% to neare%t, atan==> i% co&'Sign=!2, => and #ig"t not
be correctl' ro)nded.
L F"en e/e f tan=!2> in directed ro)nding direction #ode%, atan==> i% correctl' ro)nded to _ !2 or to
_ ne/t?&=!2>, in order to %)&&ort inter+al arit"#etic incl)%ion.
!age 54 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
0
0
0
0
0
Anne0 /
>informati-e?
Anne0 />informati-e? Alternate e0ce#tion handling mode$
00 /"! O-er-ie(
@ang)age% %"o)ld define, and re()ire i#&le#entation% to &ro+ide, #ean% for t"e )%er to attac" alternate
e/ce&tion "andling #ode% to bloc-%, lang)agedefined %'ntactic )nit% =%ee 6.2>. Alternate e/ce&tion "andler%
%&ecif' li%t% of e/ce&tion% and action% to be ta-en for eac" li%ted e/ce&tion if it i% %ignaled. 1/ce&tion li%t%
#a' contain:
L An' o&eration%&ecific e/ce&tion% =e.g. 070, YNY>. T"e na#e% are lang)agedefined.
L One of t"e fi+e e/ce&tion cla%%e%: in+alid, di+ide,'Jero, o+erflo., )nderflo., ine/act.
L all?xceptions: all of t"e afore#entioned fi+e e/ce&tion cla%%e%
All i#&le#entation% %"o)ld &ro+ide alternate e/ce&tion "andling for t"e %)&ercla%% all?xceptions, t"e fi+e
e/ce&tion cla%%e%, and o&eration%&ecific e/ce&tion% a% .ell.
@ang)age% %"o)ld &ro+ide t"e nonre%)#able alternate e/ce&tion "andling #ode% li%ted in 1.2, and t"e
re%)#able alternate e/ce&tion "andling #ode% li%ted in 1.6. T"e %'nta/ and %co&e for %)c" #ode declaration%
are lang)agedefined.
00 /"2 6on-re$+mable alternate e0ce#tion handling mode$
Aonre%)#able#ode alternate e/ce&tion "andling attac"ed to a bloc- #ean%: "andle t"e i#&lied e/ce&tion%
according to t"e nonre%)#able #ode %&ecified, t"en abandon e/ec)tion of t"e bloc- attac"ed to and re%)#e
e/ec)tion el%e."ere a% indicated. @ang)age% %"o)ld define, and re()ire i#&le#entation% to &ro+ide, t"e%e
nonre%)#able #ode%:
L ;bloc-< attac"ed to a bloc-: abandon e/ec)tion of t"e attac"ed bloc- and e/ec)te t"e alternate
bloc-. T"e e/tent to ."ic" t"e original bloc- i% e+al)ated i% lang)agedefined, %o t"e alternate
"andling bloc- %"o)ld #a-e no a%%)#&tion% abo)t +al)e% of +ariable% t"at #ig"t "a+e been c"anged.
L tran%fer attac"ed to a bloc-: tran%fer% controlQ no ret)rn &o%%ible. tran%fer i% a lang)age%&ecific
idio# for nonre%)#able control tran%ferQ con+entional lang)age% %"o)ld offer %e+eral tran%fer
idio#% %)c" a%
L goto la!el: label #ig"t be local or global according to t"e %e#antic% of t"e lang)age.
L !rea>: abandon t"e bloc- controlled b' t"i% e/ce&tion "andling and go to t"e ne/t bloc-.
L thro, exception+ame: ca)%e% an e/ce&tionAa#e not to be "andled locall', b)t rat"er %ignaled
to t"e ne/t "andling in %co&e, &er"a&% t"e f)nction t"at in+o-ed t"e c)rrent %)b&rogra#,
according to t"e %e#antic% of t"at lang)age. T"e in+o-er #ig"t "andle e/ce&tionAa#e b'
defa)lt or b' alternate "andling %)c" a% %ignaling e/ce&tionAa#e to t"e ne/t "ig"er in+o-ing
%)b&rogra#.
F"en a bloc- i% interr)&ted for nonre%)#able alternate e/ce&tion "andling, none, %o#e, or all of t"e
+ariable% a%%igned in t"at bloc- #a' be in an )ndefined %tate. So#e &rogra##ing en+iron#ent% #ig"t c"oo%e
to c"ec-&oint all +ariable% &rior to e/ec)ting t"e &rotected bloc-, and t"en re%tore t"e# &rior to e/ec)ting t"e
alternate bloc-Q ot"er% lea+e t"e re%&on%ibilit' to t"e &rogra##er to decide ."ic" +ariable% %"o)ld be
c"ec-&ointed &rior to entr' and t"en to e/&licitl' re%tore t"e# in t"e alternate bloc- a% needed.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 55
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
00 /". Re$+mable alternate e0ce#tion handling mode$
Re%)#able#ode alternate e/ce&tion "andling attac"ed to a bloc- #ean%: "andle t"e i#&lied e/ce&tion%
according to t"e re%)#able #ode declared, and contin)e e/ec)tion of t"e bloc- attac"ed to. 0#&le#entation%
%"o)ld %)&&ort t"e re%toreDefa)lt% #ode and %"o)ld %)&&ort t"e%e ot"er re%)#able #ode%:
L re%toreDefa)lt% attac"ed to a bloc-:
Re%tore% t"e =%tatic> defa)lt e/ce&tion "andling de%&ite alternate e/ce&tion "andling t"at #ig"t be in
effect in o)ter conte/t%.
L %)b%tit)te==> =a&&licable to an' e/ce&tion>:
Re&lace t"e defa)lt re%)lt of %)c" an e/ce&tional o&eration .it" a +ariable or e/&re%%ion =. T"e
ti#ing and %co&e in ."ic" = i% e+al)ated i% lang)agedefined.
L %)b%tit)te1/or==> =a&&licable to an' e/ce&tion ari%ing fro# #)lti&lication or di+i%ion>:
@i-e %)b%tit)te==>, b)t re&lace t"e defa)lt re%)lt of %)c" an e/ce&tional o&eration, if not a AaA, .it" e
=e and attac" t"e iOR of t"e %ign% of t"e o&erand%.
L abr)&t?nderflo.:
Re&lace tin' re%)lt% .it" Hero =or #ini#)# nor#al in directed ro)nding #ode%> re%)lt% of
a&&ro&riate %ign%, rai%e t"e )nderflo. flag, and %ignal ine/act.
!age 56 :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
0
0
0
0
0
Anne0 F
>informati-e?
Anne0 F>informati-e? Scaled Prod+ct O#eration$
0#&le#entation% %"o)ld &ro+ide t"e follo.ing red)ction "o#ogeneo)% co#&)tational o&eration% for all
%)&&orted non%torage floating&oint for#at%. ?nli-e t"e re%t of t"e o&eration% in t"i% %tandard, t"e%e o&erate
on arra'% of lengt" n, and #a' e+al)ate &rod)ct% in an' order and in an' .ider for#at, %o re%)lt% =incl)ding
flag%> #ig"t not be identical on different i#&le#entation%. T"e%e o&eration% #a' %ignal bot" ine/act and
in+alid. T"e%e o&eration% a+oid o+erflo. and )nderflo. to co#&)te a %caled &rod)ct pr and a %cale factor ',Q
t"e &ro&er )n%caled &rod)ct co)ld be reco+ered .it" %cale,=pr, ',> in t"e ab%ence of o+er7)nderflo.. T"e
&referred e/&onent i% 0.
L ='our*eFor+at, &og3,or+at> scaled@rod = 'our*e array, int >
;pr,',< T scaled@rod= p, n > ."ere p i% an arra' of lengt" nQ %cale,= pr, ', > co#&)te% JOi S 1,nJ pi
L ='our*eFor+at, &og3,or+at> scaled@rodEum = 'our*e array, 'our*e array, int >
;pr,',< T scaled@rodEum= p, >, n > ."ere p and > are arra'% of lengt" nQ %cale,= pr, ', > co#&)te%
JOi S 1,nJ Opi I >iJ
L ='our*eFor+at, &og3,or+at> scaled@rodDiff = 'our*e array, 'our*e array, int >
;pr,',< T scaled@rodDiff= p, >, n > ."ere p and > are arra'% of lengt" nQ %cale,= pr, ', > co#&)te%
oOi S 1,nJ Opi T >iJ
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 5$
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
Draft 1.2.5 DRAFT Standard for Floating!oint Arit"#etic !$54
October 4, 2006
0
0
0
0
0
Anne0 2
>informati-e?
Anne0 2 >informati-e? Program deb+gging $+##ort
00 2"! O-er-ie(
0#&le#entation% of t"i% %tandard +ar' in t"e &rioritie% t"e' a%%ign to c"aracteri%tic% li-e &erfor#ance and
deb)ggabilit' =t"e abilit' to deb)g>. T"i% anne/ de%cribe% %o#e &rogra##ing en+iron#ent feat)re% t"at
%"o)ld be &ro+ided b' i#&le#entation% t"at intend to %)&&ort #a/i#)# deb)ggabilit'. On %o#e
i#&le#entation%, enabling %o#e of t"e%e abilitie% #a' be +er' e/&en%i+e in &erfor#ance co#&ared to f)ll'
o&ti#iHed code.
Deb)gging incl)de% finding t"e origin% of and rea%on% for n)#erical %en%iti+it' or e/ce&tion%, finding
&rogra##ing error% %)c" a% acce%%ing )ninitialiHed %torage t"at are onl' #anife%ted a% incorrect n)#erical
re%)lt%, and te%ting candidate fi/e% for &roble#% t"at are fo)nd.
00 2"2 6+merical $en$iti-it'
Deb)gger% %"o)ld be able to alter t"e #ode% go+erning "andling of e/ce&tion% in%ide %)b&rogra#%, e+en if t"e
%o)rce code for t"o%e %)b&rogra#% i% not a+ailable. For in%tance, c"anging t"e ro)nding direction or &reci%ion
d)ring e/ec)tion #a' "el& identif' %)b&rogra#% t"at are )n)%)all' %en%iti+e to ro)ndoff, ."et"er d)e to ill
condition of t"e &roble# being %ol+ed, in%tabilit' in t"e algorit"# c"o%en, or an algorit"# de%igned to .or-
in onl' one ro)nding direction #ode. T"e )lti#ate goal i% to deter#ine re%&on%ibilit' for n)#erical
#i%be"a+ior, e%&eciall' in %e&aratel'co#&iled %)b&rogra#%. T"e #ean% to ac"ie+e t"at goal i% to facilitate
t"e &rod)ction of %#all re&rod)cible te%t ca%e% t"at elicit )ne/&ected be"a+ior.
00 2". 6+merical e0ce#tion$
Deb)gger% %"o)ld be able to detect and &a)%e to t"e deb)gger ."en a &re%&ecified e/ce&tion i% %ignaled
.it"in a &artic)lar %)b&rogra#, or .it"in %&ecified %)b&rogra#% t"at it call%. To a+oid conf)%ion, t"e &a)%e
%"o)ld "a&&en %oon after t"e e+ent ."ic" &reci&itated t"e &a)%e. After %)c" a &a)%e, t"e deb)gger %"o)ld be
able to contin)e e/ec)tion a% if t"e e/ce&tion "ad been "andled b' an alternate "andler if %&ecified, or
ot"er.i%e b' t"e defa)lt "andler. T"e &a)%e i% a%%ociated .it" an e/ce&tion and #ig"t not be a%%ociated .it"
a .elldefined %o)rcecode %tate#ent bo)ndar'Q in%i%ting on &a)%e% t"at are &reci%e .it" re%&ect to t"e %o)rce
code #a' .ell in"ibit o&ti#iHation.
Deb)gger% %"o)ld be able to rai%e and lo.er %tat)% flag%.
Deb)gger% %"o)ld be able to e/a#ine all t"e )nre()ited e/ce&tion% left %tanding at t"e end of a %)b&rogra#M%
or ."ole &rogra#M% e/ec)tion. T"e%e ca&abilitie% %"o)ld be en"anced b' i#&le#enting eac" %tat)% flag a% a
reference to a detailed record of it% origin and "i%tor'. ,' defa)lt, e+en a %)b&rogra# &re%)#ed to be
deb)gged %"o)ld at lea%t in%ert a reference to it% na#e in an e/ce&tion flag and in t"e &a'load of an' ne.
()iet AaA &rod)ced a% a floating&oint re%)lt of an in+alid o&eration. T"e%e reference% indicate t"e origin of
t"e e/ce&tion or AaA.
Deb)gger% %"o)ld be able to #aintain table% of "i%torie% of ()iet AaA%, )%ing t"e AaA &a'load to inde/ t"e
table%.
Deb)gger% %"o)ld be able to &a)%e at e+er' floating&oint o&eration, .it"o)t di%r)&ting a &rogra#M% logic for
dealing .it" e/ce&tion%. Deb)gger% %"o)ld di%&la' %o)rce code line% corre%&onding to #ac"ine in%tr)ction%
."ene+er &o%%ible.
For +ario)% &)r&o%e% a %ignaling AaA co)ld be )%ed a% a reference to a record containing a n)#erical +al)e
e/tended b' an e/ce&tion "i%tor', e/tra e/&onent, or e/tra %ignificand. :on%e()entl' deb)gger% %"o)ld be
able to ca)%e bit.i%e o&eration% li-e negate, ab%, and co&'Sign, ."ic" are nor#all' %ilent, to detect %ignaling
!age 5B :o&'rig"t I 2006 0111. All rig"t% re%er+ed.
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.
DRAFT Standard for Floating!oint Arit"#etic !$54 Draft 1.2.5
October 4, 2006
AaA%. F)rt"er#ore t"e %ignaling attrib)te of %ignaling AaA% %"o)ld be able to be enabled or di%abled
globall' or .it"in a &artic)lar conte/t, .it"o)t di%r)&ting or being affected b' a &rogra#M% logic for defa)lt or
alternate "andling of ot"er in+alid e/ce&tion%.
00 2"4 Programming error$
Deb)gger% %"o)ld be able to define %o#e or all AaA% a% %ignaling AaA% t"at %ignal an e/ce&tion e+er' ti#e
t"e' are )%ed. 0n for#at% .it" %)&erfl)o)% bit &attern% not generated b' arit"#etic, %)c" a% noncanonical
%ignificand field% in deci#al for#at%, deb)gger% %"o)ld be able to enable %ignalingAaA be"a+ior for data
containing %)c" bit &attern%. Deb)gger% %"o)ld be able to ca)%e noncanonical %ignificand field% to %ignal an
e/ce&tion.
Deb)gger% %"o)ld be able to %et )ninitialiHed %torage and +ariable%, %)c" a% "ea& and co##on %&ace to
%&ecific bit &attern% %)c" a% allHero% or allone% ."ic" are "el&f)l for finding inad+ertent )%age% of %)c"
+ariable%Q t"o%e )%age% #a' &ro+e refractor' to %tatic anal'%i% if t"e' in+ol+e #)lti&le alia%e% to t"e %a#e
&"'%ical %torage.
More "el&f)l, and re()iring corre%&ondingl' #ore %oft.are coordination to i#&le#ent, are deb)gging
en+iron#ent% in ."ic" all floating&oint +ariable%, incl)ding a)to#atic +ariable% eac" ti#e t"e' are allocated
on a %tac-, are initialiHed to %ignaling AaA% t"at reference %'#bol table entrie% de%cribing t"eir origin in ter#%
of t"e %o)rce &rogra#. S)c" initialiHation .o)ld be e%&eciall' )%ef)l in an en+iron#ent in ."ic" t"e
deb)gger i% able to &a)%e e/ec)tion ."en a &re%&ecified e/ce&tion i% %ignaled or flag i% rai%ed.
:o&'rig"t I 2006 0111. All rig"t% re%er+ed. !age 52
T"i% i% an )na&&ro+ed draft, %)b*ect to c"ange.

Вам также может понравиться