5.3 Elementary transcendental oating point operations
5.3.7 Operations for argument angular-unit trigonometrics and inverse argument
5.3.7.8 Argument angular-unit cosecantus operation
The
cscu
F approximation helper function:cscu
F :F
R!Rcscu
F(u;x
) returns a close approximation to csc(x
2=u
) in R ifu
6= 0, with maximum errormax error tanu
F(u
).Further requirements on the
cscu
F approximation helper function:cscu
F(u;n
u
+x
) =cscu
F(u;x
) ifn
2Z andu
2F
andu
20cscu
F(u;u=
12) = 2 ifu
2F
andu
6= 0cscu
F(u;u=
4) = 1 ifu
2F
andu
6= 0cscu
F(u;
5u=
12) = 2 ifu
2F
andu
6= 0cscu
F(u;
,x
) =,cscu
F(u;x
) ifu
2F
andu
6= 0cscu
F(,u;x
) =,cscu
F(u;x
) ifu
2F
andu
6= 0 Thecscu
F operation:cscu
F :F
F
!F
[fpole ; oating over ow ; invalid ; angle too big
gcscu
F(u;x
) =trans result
F(cscu
F(u;x
))if
cycle
F(u;x
)2F
andcycle
F(u;x
)62f,u=
2;
0;u=
2g=
pole
(+1) ifcycle
F(u;x
) = 0=
pole
(,1) ifcycle
F(u;x
) =,0
=
pole
(+1) ifcycle
F(u;x
) =u=
2=
pole
(,1) ifcycle
F(u;x
) =,u=
2=
angle too big
(qNaN
) ifu
2G
F andx
2F
and jx=u
j> big angle u
F=
invalid
(qNaN
) ifu
2F
and ju
j< min angular unit
F andx
2F
[f,0
g=
invalid
(qNaN
) ifu
2f,1;
,0 ;
+1g andx
2F
[f,1;
,0 ;
+1g=
invalid
(qNaN
) ifu
2F
andx
2f,1;
+1g=
qNaN
ifx
is a quiet NaN andu
is not a signalling NaN=
qNaN
ifu
is a quiet NaN andx
is not a signalling NaN=
invalid
(qNaN
) ifx
is a signalling NaN oru
is a signalling NaNThird Committee Draft ISO/IEC CD 10967-2.3:1998(E) 5.3.7.9 Argument angular-unit arcus sinus operation
The
arcsinu
F approximation helper function:arcsinu
F :F
F
!Rarcsinu
F(u;x
) returns a close approximation to arcsin(x
)u=
(2) in R, with maximum errormax error sinu
F(u
).Further requirements on the
arcsinu
F approximation helper function:arcsinu
F(u;
1=
2) =u=
12arcsinu
F(u;
1) =u=
4arcsinu
F(u;
,x
) =,arcsinu
F(u;x
)arcsinu
F(,u;x
) =,arcsinu
F(u;x
)NOTE { arcsinuF(u;x)u=(2) ifjxj<fminNF. The
arcsinu
F operation:arcsinu
F :F
F
!F
[f,0 ; under ow ; invalid
garcsinu
F(u;x
)=
trans result
F(arcsinu
F(u;x
))if
u
2G
F andx
2F
and jx
j1 andx
6= 0= 0 if
u
2G
F andu >
0 andx
= 0=,
0
ifu
2G
F andu >
0 andx
=,0
=,
0
ifu
2G
F andu <
0 andx
= 0= 0 if
u
2G
F andu <
0 andx
=,0
=
invalid
(qNaN
) ifu
2G
F andx
2F
and jx
j>
1=
invalid
(qNaN
) ifu
2G
F andx
2f,1;
+1g=
invalid
(qNaN
) ifu
2F
and ju
j< min angular unit
F andx
2F
[f,1;
,0 ;
+1g=
invalid
(qNaN
) ifu
2f,1;
,0 ;
+1gandx
2F
[f,1;
,0 ;
+1g=
qNaN
ifx
is a quiet NaN andu
is not a signalling NaN=
qNaN
ifu
is a quiet NaN andx
is not a signalling NaN=
invalid
(qNaN
) ifx
is a signalling NaN oru
is a signalling NaN5.3.7.10 Argument angular-unit arcus cosinus operation
The
arccosu
F approximation helper function:arccosu
F :F
F
!Rarccosu
F(u;x
) returns a close approximation to arccos(x
)u=
(2) in R, with maximum errormax error sinu
F(u
).Further requirements on the
arccosu
F approximation helper function:arccosu
F(u;
1=
2) =u=
6arccosu
F(u;
0) =u=
4arccosu
F(u;
,1=
2) =u=
3arccosu
F(u;
,1) =u=
2arccosu
F(,u;x
) =,arccosu
F(u;x
) Thearccosu
F operation:arccosu
F :F
F
!F
[funder ow ; invalid
gISO/IEC CD 10967-2.3:1998(E) Third Committee Draft arccosu
F(u;x
)=
trans result
F(arccosu
F(u;x
))if
u
2G
F andx
2F
and jx
j1=
trans result
F(u=
4) ifu
2G
F andx
=,0
=
invalid
(qNaN
) ifu
2G
F andx
2F
and jx
j>
1=
invalid
(qNaN
) ifu
2G
F andx
2f,1;
+1g=
invalid
(qNaN
) ifu
2F
and ju
j< min angular unit
F andx
2F
[f,1;
,0 ;
+1g=
invalid
(qNaN
) ifu
2f,1;
,0 ;
+1g andx
2F
[f,1;
,0 ;
+1g=
qNaN
ifx
is a quiet NaN andu
is not a signalling NaN=
qNaN
ifu
is a quiet NaN andx
is not a signalling NaN=
invalid
(qNaN
) ifx
is a signalling NaN oru
is a signalling NaN5.3.7.11 Argument angular-unit arcus operation
The
arcu
F approximation helper function:arcu
F :F
F
F
!Rarcu
F(u;x;y
) returns a close approximation toarc
(x;y
)u=
(2) inR, with maximum errormax error tanu
F(u
).Further requirements on the
arcu
F approximation helper function:arcu
F(u;x;x
) =u=
8 ifx >
0arcu
F(u;
0;y
) =u=
4 ify >
0arcu
F(u;x;
,x
) = 3u=
8 ifx <
0arcu
F(u;x;
0) =u=
2 ifx <
0arcu
F(u;x;
,y
) =,arcu
F(u;x;y
) ify
6= 0 orx >
0arcu
F(,u;x;y
) =,arcu
F(u;x;y
)The
arcu
F operation:arcu
F :F
F
F
!F
[f,0 ; under ow ; invalid
garcu
F(u;x;y
) =trans result
F(arcu
F(u;x;y
))if
u
2G
F andx;y
2F
and (x <
0 ory
6= 0)=
mul
F(u;
0) ifu
2G
F andx
2F
andx >
0 andy
= 0=
invalid
(0) ifu
2G
F andx
= 0 andy
= 0=
arcu
F(u;
0;y
) ifu
2G
F andx
=,0
andy
2F
[f,1;
,0 ;
+1g=
neg
F(arcu
F(u;x;
0)) ifu
2G
F andy
=,0
andx
2F
[f,1;
+1g=
mul
F(0;u
) ifu
2G
F andx
= +1 andy
2F
andy
0=
mul
F(neg
F(0);u
) ifu
2G
F andx
= +1 andy
2F
andy <
0=
nearest
F(u=
8)?inval? ifu
2G
F andx
= +1 andy
= +1=
nearest
F(u=
4) ifu
2G
F andx
2F
andy
= +1=
nearest
F(3u=
8)?inval?ifu
2G
F andx
=,1 andy
= +1=
nearest
F(u=
2) ifu
2G
F andx
=,1 andy
2F
andy
0=
nearest
F(,u=
2) ifu
2G
F andx
=,1 andy
2F
andy <
0=
nearest
F(,3u=
8)?inval?ifu
2G
F andx
=,1 andy
=,1=
nearest
F(,u=
4) ifu
2G
F andx
2F
andy
=,1=
nearest
F(,u=
8)?inval? ifu
2G
F andx
= +1 andy
=,1=
invalid
(qNaN
) ifu
2F
and ju
j< min angular unit
F andThird Committee Draft ISO/IEC CD 10967-2.3:1998(E) x
2F
[f,1;
,0 ;
+1g=
invalid
(qNaN
) ifu
2f,1;
,0 ;
+1gandx;y
2F
[f,1;
,0 ;
+1g=
qNaN
ifu
is a quiet NaN and notx
nory
is a signalling NaN=
qNaN
ifx
is a quiet NaN and notu
nory
is a signalling NaN=
qNaN
ify
is a quiet NaN and notu
norx
is a signalling NaN=
invalid
(qNaN
) ifu
is a signalling NaN orx
is a signalling NaN ory
is a signalling NaN5.3.7.12 Argument angular-unit arcus tangentus operation
The
arctanu
F approximation helper function:arctanu
F :F
F
!Rarctanu
F(u;x
) returns a close approximation to arctan(x
)u=
(2) in R, with maximum errormax error tanu
F(u
).Further requirements on the
arctanu
F approximation helper function:arctanu
F(u;
1) =u=
8arctanu
F(u;x
) =u=
4 ifarctanu
F(u;x
)6= arctan(x
)u=
(2) andx >
3r
F=epsilon
Farctanu
F(u;
,x
) =,arctanu
F(u;x
)arctanu
F(,u;x
) =,arctanu
F(u;x
)NOTE 1 { arctanuF(u;x)u=(2) ifjxj<fminNF The
arctanu
F operation:arctanu
F :F
F
!F
[f,0 ; invalid ; under ow
garctanu
F(u;x
)=
trans result
F(arctanu
F(u;x
))if
u
2G
F andx
2F
andx
6= 0= 0 if
u
2G
F andu >
0 andx
= 0=,
0
ifu
2G
F andu >
0 andx
=,0
=,
0
ifu
2G
F andu <
0 andx
= 0= 0 if
u
2G
F andu <
0 andx
=,0
=
trans result
F(,u=
4) ifu
2G
F andx
=,1=
trans result
F(u=
4) ifu
2G
F andx
= +1=
invalid
(qNaN
) ifu
2F
and ju
j< min angular unit
F andx
2F
[f,1;
,0 ;
+1g=
invalid
(qNaN
) ifu
2f,1;
,0 ;
+1gandx
2F
[f,1;
,0 ;
+1g=
qNaN
ifx
is a quiet NaN andu
is not a signalling NaN=
qNaN
ifu
is a quiet NaN andx
is not a signalling NaN=
invalid
(qNaN
) ifx
is a signalling NaN oru
is a signalling NaN NOTE 2 { arctanuF(u;x)arcuF(u;1;x).5.3.7.13 Argument angular-unit arcus cotangentus operation
The
arccotu
F andarcctgu
F approximation helper functions:arccotu
F :F
F
!Rarcctgu
F :F
F
!RISO/IEC CD 10967-2.3:1998(E) Third Committee Draft arccotu
F(u;x
) returns a close approximation to arccot(x
)u=
(2) in R, with maximum errormax error tanu
F(u
).arcctgu
F(u;x
) returns a close approximation to arcctg(x
)u=
(2) in R, with maximum errormax error tanu
F(u
).There are two reasonable ways of selecting the principle value for the inverse of the cot oper.
It is best to leave it to the user/programmer to decide which one is the most appropriate in a particular application. LIA-2 species both of them. Selecting just one is premature at the LIA level.
Further requirements on the
arccotu
F andarccotu
F approximation helper functions:arccotu
F(u;
1) =u=
8arccotu
F(u;
0) =u=
4arccotu
F(u;
,1) = 3u=
8arccotu
F(u;x
)u=
2 ifu >
0arccotu
F(u;x
)u=
2 ifu <
0arccotu
F(u;x
) =u=
2 ifarccotu
F(u;x
)6= arccot(x
)u=
(2) andx <
,3r
F=epsilon
Farccotu
F(,u;x
) =,arccotu
F(u;x
)arcctgu
F(u;x
) =arccotu
F(u;x
) ifx
0arcctgu
F(u;
,x
) =,arcctgu
F(u;x
)The
arccotu
F operation:arccotu
F :F
F
!F
[finvalid ; under ow
garccotu
F(u;x
) =trans result
F(arccotu
F(u;x
))if
u
2G
F andx
2F
=
trans result
F(u=
4) ifu
2G
F andx
=,0
=
trans result
F(u=
2) ifu
2G
F andx
=,1= 0 if
u
2G
F andu >
0 andx
= +1=,
0
ifu
2G
F andu <
0 andx
= +1=
invalid
(qNaN
) ifu
2F
and ju
j< min angular unit
F andx
2F
[f,1;
,0 ;
+1g=
invalid
(qNaN
) ifu
2f,1;
,0 ;
+1g andx
2F
[f,1;
,0 ;
+1g=
qNaN
ifx
is a quiet NaN andu
is not a signalling NaN=
qNaN
ifu
is a quiet NaN andx
is not a signalling NaN=
invalid
(qNaN
) ifx
is a signalling NaN oru
is a signalling NaN NOTE { arccotuF(u;x)arcuF(u;x;1).The
arcctgu
F operation:arcctgu
F :F
F
!F
[finvalid ; under ow
garcctgu
F(u;x
) =trans result
F(arcctgu
F(u;x
))if
u
2G
F andx
2F
=
trans result
F(,u=
4) ifu
2G
F andx
=,0
=,
0
ifu
2G
F andu >
0 andx
=,1= 0 if
u
2G
F andu >
0 andx
= +1= 0 if
u
2G
F andu <
0 andx
=,1=,
0
ifu
2G
F andu <
0 andx
= +1=
invalid
(qNaN
) ifu
2F
and ju
j< min angular unit
F andThird Committee Draft ISO/IEC CD 10967-2.3:1998(E) x
2F
[f,1;
,0 ;
+1g=
invalid
(qNaN
) ifu
2f,1;
,0 ;
+1gandx
2F
[f,1;
,0 ;
+1g=
qNaN
ifx
is a quiet NaN andu
is not a signalling NaN=
qNaN
ifu
is a quiet NaN andx
is not a signalling NaN=
invalid
(qNaN
) ifx
is a signalling NaN oru
is a signalling NaN5.3.7.14 Argument angular-unit arcus secantus operation
The
arcsecu
F approximation helper function:arcsecu
F :F
F
!Rarcsecu
F(u;x
) returns a close approximation to arcsec(x
)u=
(2) in R, with maximum errormax error tanu
F(u
).Further requirements on the
arcsecu
F approximation helper function:arcsecu
F(u;
2) =u=
6arcsecu
F(u;
,2) =u=
3arcsecu
F(u;
,1) =u=
2arcsecu
F(u;x
)u=
4 ifx >
0 andu >
0arcsecu
F(u;x
)u=
4 ifx <
0 andu >
0arcsecu
F(u;x
) =u=
4 ifarcsecu
F(u;x
)6= arcsec(x
)u=
(2) andj
x
j>
3r
F=epsilon
Farcsecu
F(,u;x
) =,arcsecu
F(u;x
) Thearcsecu
F operation:arcsecu
F :F
F
!F
[funder ow ; invalid
garcsecu
F(u;x
) =trans result
F(arcsecu
F(u;x
))if
u
2G
F andx
2F
and (x
,1 orx
1)=
invalid
(qNaN
) ifu
2G
F andx
2F
and ,1< x <
1=
invalid
(qNaN
) ifu
2G
F andx
=,0
=
trans result
F(u=
4) ifu
2G
F andx
=,1=
trans result
F(u=
4) ifu
2G
F andx
= +1=
invalid
(qNaN
) ifu
2F
and ju
j< min angular unit
F andx
2F
[f,1;
,0 ;
+1g=
invalid
(qNaN
) ifu
2f,1;
,0 ;
+1gandx
2F
[f,1;
,0 ;
+1g=
qNaN
ifx
is a quiet NaN andu
is not a signalling NaN=
qNaN
ifu
is a quiet NaN andx
is not a signalling NaN=
invalid
(qNaN
) ifx
is a signalling NaN oru
is a signalling NaN5.3.7.15 Argument angular-unit arcus cosecantus operation
The
arccscu
F approximation helper function:arccscu
F :F
F
!Rarccscu
F(u;x
) returns a close approximation to arccsc(x
)u=
(2) in R, with maximum errormax error tanu
F(u
).Further requirements on the
arccscu
F approximation helper function:ISO/IEC CD 10967-2.3:1998(E) Third Committee Draft arccscu
F(u;
2) =u=
12arccscu
F(u;
1) =u=
4arccscu
F(u;
,x
) =,arccscu
F(u;x
)arccscu
F(,u;x
) =,arccscu
F(u;x
) Thearccscu
F operation:arccscu
F :F
F
!F
[funder ow ; invalid
garccscu
F(u;x
) =trans result
F(arccscu
F(u;x
))if
u
2G
F andx
2F
and (x
1 orx
,1)=
invalid
(qNaN
) ifu
2G
F andx
2F
and ,1< x <
1=
invalid
(qNaN
) ifu
2G
F andx
=,0
=,
0
ifu
2G
F andu >
0 andx
=,1= 0 if
u
2G
F andu >
0 andx
= +1= 0 if
u
2G
F andu <
0 andx
=,1=,
0
ifu
2G
F andu <
0 andx
= +1=
invalid
(qNaN
) ifu
2F
andu < min angular unit
F andx
2F
[f,1;
,0 ;
+1g=
invalid
(qNaN
) ifu
2f,1;
,0 ;
+1g andx
2F
[f,1;
,0 ;
+1g=
qNaN
ifx
is a quiet NaN andu
is not a signalling NaN=
qNaN
ifu
is a quiet NaN andx
is not a signalling NaN=
invalid
(qNaN
) ifx
is a signalling NaN oru
is a signalling NaN5.3.8 Operations for degree trigonometrics and inverse degree trigonometrics deg
F :F
!F
[f,0 ; angle too big
gdeg
F(x
) =unit
F(360;x
)sind
F :F
!F
[f,0 ; under ow ; angle too big
gsind
F(x
) =sinu
F(360;x
)cosd
F :F
!F
[funder ow ; angle too big
gcosd
F(x
) =cosu
F(360;x
)cossind
F :F
!F
(F
[f,0
g)[funder ow ; angle too big
gcossind
F(x
) =cossinu
F(360;x
)tand
F :F
!F
[f,0 ; pole ; oating over ow ; under ow ; angle too big
gtand
F(x
) =tanu
F(360;x
)cotd
F :F
!F
[fpole ; oating over ow ; under ow ; angle too big
gcotd
F(x
) =cotu
F(360;x
)secd
F :F
!F
[fpole ; oating over ow ; angle too big
gsecd
F(x
) =secu
F(360;x
)cscd
F :F
!F
[fpole ; oating over ow ; angle too big
gcscd
F(x
) =cscu
F(360;x
)arcsind
F :F
!F
[funder ow ; invalid
garcsind
F(x
) =arcsinu
F(360;x
)arccosd
F :F
!F
[finvalid
garccosd
F(x
) =arccosu
F(360;x
)arcd
F :F
F
!F
[funder ow ; invalid
garcd
F(x;y
) =arcu
F(360;x;y
)Third Committee Draft ISO/IEC CD 10967-2.3:1998(E) arctand
F :F
!F
[funder ow
garctand
F(x
) =arctanu
F(360;x
)arccotd
F :F
!F
[funder ow
garccotd
F(x
) =arccotu
F(360;x
)arcctgd
F :F
!F
[funder ow
garcctgd
F(x
) =arcctgu
F(360;x
)arcsecd
F :F
!F
[finvalid
garcsecd
F(x
) =arcsecu
F(360;x
)arccscd
F :F
!F
[funder ow ; invalid
garccscd
F(x
) =arccscu
F(360;x
)5.3.9 Operations for angular-unit conversions
5.3.9.1 Converting radian angle to argument angular-unit angle
Dene the mathematical function:
rad to cycle
:RR!Rrad to cycle
(x;v
)= arccos(cos(
x
))v=
(2)if sin(
x
)0 andv
6= 0=,arccos(cos(
x
))v=
(2)if sin(
x
)<
0 andv
6= 0 Therad to cycle
F approximation helper function:rad to cycle
F :RF
!Rrad to cycle
F(x;v
) returns a close approximation torad to cycle
(x;v
) in R, with maximum errormax error rad
F, if jx
jbig angle r
F.Further requirements on the
rad to cycle
F approximation helper function:rad to cycle
F(n
2+=
6;v
) =v=
12 ifn
2Z and jn
2+=
6jbig angle r
Frad to cycle
F(n
2+=
4;v
) =v=
8 ifn
2Z and jn
2+=
4jbig angle r
Frad to cycle
F(n
2+=
3;v
) =v=
6 ifn
2Z and jn
2+=
3jbig angle r
Frad to cycle
F(n
2+=
2;v
) =v=
4 ifn
2Z and jn
2+=
2jbig angle r
Frad to cycle
F(n
2+ 2=
3;v
) =v=
3if
n
2Z and jn
2+ 2=
3jbig angle r
Frad to cycle
F(n
2+ 3=
4;v
) = 3v=
8if
n
2Z and jn
2+ 3=
4jbig angle r
Frad to cycle
F(n
2+ 5=
6;v
) = 5v=
12if
n
2Z and jn
2+ 5=
6jbig angle r
Frad to cycle
F(n
2+;v
) =v=
2 ifn
2Z and jn
2+jbig angle r
Frad to cycle
F(,x;v
) =,rad to cycle
F(x;v
)if
rad to cycle
(x;v
)6=v=
2rad to cycle
F(x;
,v
) =,rad to cycle
F(x;v
)if
rad to cycle
(x;v
)6=v=
2 Therad to cycle
F operation:rad to cycle
F :F
F
!F
[funder ow ; angle too big ; invalid
gISO/IEC CD 10967-2.3:1998(E) Third Committee Draft
5.3.9.2 Converting argument angular-unit angle to radian angle
Dene the mathematical function: The
cycle to rad
F approximation helper function:cycle to rad
F :F
R!Rcycle to rad
F(u;x
) returns a close approximation tocycle to rad
(u;x
) in R, ifu
6= 0, with maximum errormax error rad
F.Further requirements on the
cycle to rad
F approximation helper function:cycle to rad
F(u;n
u
+x
) =cycle to rad
F(u;x
)Third Committee Draft ISO/IEC CD 10967-2.3:1998(E) 5.3.9.3 Converting argument unit angle to (another) argument
angular-unit angle
Thecycle to cycle
F approximation helper function:cycle to cycle
F :F
RF
!Rcycle to cycle
F(u;x;v
) returns a close approximation tocycle to cycle
(u;x;v
) in R ifu
6= 0 andjx=u
jbig angle u
F, with maximum errormax error rad
F.Further requirements on the
cycle to cycle
F approximation helper function:cycle to cycle
F(u;n
u
+x;v
) =cycle to cycle
F(u;x;v
)ISO/IEC CD 10967-2.3:1998(E) Third Committee Draft 5.3.9.4 Degree angle conversions to and from other angular units
rad to deg
F :F
!F
[funder ow ; angle too big
grad to deg
F(x
)=rad to cycle
F(x;
360)deg to rad
F :F
!F
[f,0 ; under ow ; angle too big
gdeg to rad
F(x
) =cycle to rad
F(360;x
)cycle to deg
F :F
F
!F
[f,0 ; under ow ; angle too big ; invalid
gcycle to deg
F(u;x
) =cycle to cycle
F(u;x;
360)deg to cycle
F :F
F
!F
[f,0 ; under ow ; angle too big ; invalid
gdeg to cycle
F(x;v
) =cycle to cycle
F(360;x;v
)5.4 Conversion operations
Fixed point string formats and oating point string formats should have formats for ,
0
, +1,,1, quiet and signalling NaNs. Integer string formats may have formats for such values.
NOTES
1 In ordinary string formats for numerals, the string \Hello world!" is an example of a signalling NaN.
2 This part of ISO/IEC 10967does not specify any string formats, not even for the special values,0, +1,,1, and quiet NaN, but possibilities include the strings used in the text of this part of ISO/IEC 10967, as well as strings like \+innity" or \positiva oandligheten", etc, and the strings used may depend on preference settings. String formats for numerical values, and if and how they may depend on preference settings, is also an issue for bindings or programming language specications. It is not an issue for this part of ISO/IEC 10967.
5.4.1 Integer to integer conversions
I
andI
0 represent dierent integer data types (even if the setsI
andI
0 are the same). At least one ofI
andI
0conform to LIA-1.NOTE 1 { If both are I and I0 are conforming to ISO/IEC 10967-1, then this conversion is covered by ISO/IEC 10967-1. This operation generalises the cvtI!I0 of ISO/IEC 10967-1:1994, with respect to that one of the integer types in the conversion need not be conforming to ISO/IEC 10967-1.
convert
I!I0 :I
!I
0[finteger over ow
gconvert
I!I0(x
)=result
I0(x
) ifx
2I
=,
0
ifx
=,0
and ,0
is available in the target type=,1 if
x
=,1 and,1 is available in the target type= +1 if
x
= +1 and +1 is available in the target type= 0 if
x
=,0
and ,0
is not available in the target type=
integer over ow
ifx
=,1 and,1 is not available in the target type=
integer over ow
ifx
= +1 and +1 is not available in the target type=
qNaN
ifx
is a quiet NaN and quiet NaN is available in the target type=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]NOTE 2 { This covers, among other things, \input" and \output" of integer type values, including the possibility of over ow (for either input or output).
Third Committee Draft ISO/IEC CD 10967-2.3:1998(E) 5.4.2 Floating point to integer conversions
I
is an ISO/IEC 10967-1 conforming integer type.F
is an ISO/IEC 10967-1 conforming oating point type.NOTE { The operations in this clause are more specic than the oating point to integer conversion in ISO/IEC 10967-1:1994 which allows any rounding.
rounding
F!I :F
!I
[finteger over ow
grounding
F!I(x
)=
result
I(round(x
)) ifx
2F
=,
0
ifx
=,0
and ,0
is available in the target type=,1 if
x
=,1and ,1is available in the target type= +1 if
x
= +1 and +1 is available in the target type= 0 if
x
=,0
and ,0
is not available in the target type=
integer over ow
ifx
=,1and ,1is not available in the target type=
integer over ow
ifx
= +1 and +1 is not available in the target type=
qNaN
ifx
is a quiet NaN and quiet NaN is available in the target type=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]oorF!I :
F
!I
[finteger over ow
goorF!I(
x
) =result
I(bx
c) ifx
2F
=,
0
ifx
=,0
and ,0
is available in the target type=,1 if
x
=,1and ,1is available in the target type= +1 if
x
= +1 and +1 is available in the target type= 0 if
x
=,0
and ,0
is not available in the target type=
integer over ow
ifx
=,1and ,1is not available in the target type=
integer over ow
ifx
= +1 and +1 is not available in the target type=
qNaN
ifx
is a quiet NaN and quiet NaN is available in the target type=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]ceiling
F!I :F
!I
[finteger over ow
gceiling
F!I(x
) =result
I(dx
e) ifx
2F
=,
0
ifx
=,0
and ,0
is available in the target type=,1 if
x
=,1and ,1is available in the target type= +1 if
x
= +1 and +1 is available in the target type= 0 if
x
=,0
and ,0
is not available in the target type=
integer over ow
ifx
=,1and ,1is not available in the target type=
integer over ow
ifx
= +1 and +1 is not available in the target type=
qNaN
ifx
is a quiet NaN and quiet NaN is available in the target type=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]5.4.3 Integer to oating point conversions convert
nearestI!F :I
!F
[foating over ow
gconvert
nearestI!F (x
)=result
F(x;nearest
F) ifx
2I
=,
0
ifx
=,0
and ,0
is available in the target type=,1 if
x
=,1and ,1is available in the target typeISO/IEC CD 10967-2.3:1998(E) Third Committee Draft
= +1 if
x
= +1 and +1 is available in the target type= 0 if
x
=,0
and ,0
is not available in the target type=
oating over ow
ifx
=,1 and,1 is not available in the target type=
oating over ow
ifx
= +1 and +1 is not available in the target type=
qNaN
ifx
is a quiet NaN and quiet NaN is available in the target type=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]The following two operations are to support interval arithmetic.
convert
downI!F :I
!F
[foating over ow
g=
oating over ow
ifx
=,1 and,1 is not available in the target type=
oating over ow
ifx
= +1 and +1 is not available in the target type=
qNaN
ifx
is a quiet NaN and quiet NaN is available in the target type=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]convert
upI!F :I
!F
[foating over ow
g=
oating over ow
ifx
=,1 and,1 is not available in the target type=
oating over ow
ifx
= +1 and +1 is not available in the target type=
qNaN
ifx
is a quiet NaN and quiet NaN is available in the target type=
invalid
(qNaN
) if x is a signalling NaN [sNaN
without notication?]NOTE { Integer to nearest oating point conversions are covered by ISO/IEC 10967-1. I.e.
cvtI!F = convertnearestI!F , when both I and F conform to LIA-1.
5.4.4 Floating point to oating point conversions
F
andF
0 represent dierent oating point data types (even if the setsF
andF
0 are the same).At least one of
F
andF
0 conform to LIA-1.=
oating over ow
ifx
=,1 and,1 is not available in the target type=
oating over ow
ifx
= +1 and +1 is not available in the target type=
qNaN
ifx
is a quiet NaN and quiet NaN isThird Committee Draft ISO/IEC CD 10967-2.3:1998(E)
available in the target type
=
invalid
(qNaN
) if x is a signalling NaN [sNaN
without notication?]The following two operations are to support interval arithmetic.
convert
downF!F0 :F
!F
0[foating over ow ; under ow
gconvert
downF!F0(x
)=
result
F0(x;down
F0) ifx
2F
=,
0
ifx
=,0
and ,0
is available in the target type=,1 if
x
=,1and ,1is available in the target type= +1 if
x
= +1 and +1 is available in the target type= 0 if
x
=,0
and ,0
is not available in the target type=
oating over ow
ifx
=,1and ,1is not available in the target type=
oating over ow
ifx
= +1 and +1 is not available in the target type=
qNaN
ifx
is a quiet NaN and quiet NaN is available in the target type=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]convert
upF!F0 :F
!F
0[foating over ow ; under ow
gconvert
upF!F0(x
)=
result
F0(x;up
F0) ifx
2F
=,
0
ifx
=,0
and ,0
is available in the target type=,1 if
x
=,1and ,1is available in the target type= +1 if
x
= +1 and +1 is available in the target type= 0 if
x
=,0
and ,0
is not available in the target type=
oating over ow
ifx
=,1and ,1is not available in the target type=
oating over ow
ifx
= +1 and +1 is not available in the target type=
qNaN
ifx
is a quiet NaN and quiet NaN is available in the target type=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]NOTES
1 Floating point to nearest oating point conversions are covered by ISO/IEC 10967-1 when both types conform to ISO/IEC 10967-1.
2 This covers, among other things, \input" and \output" of oating point type values, for oating point string formats.
5.4.5 Floating point to xed point conversions
D
is a xed point type (essentially LID scaled, but it may be limited). A xed point type D shall be a subset of R, characterised by a radix,r
D 2 Z (2), a density,d
D 2Z (0), and if it is limited a maximum positive value,dmax
D 2D
(1). Given these values, the following sets are dened:D
=fn=
(r
dDD) jn
2Z
gD
=D
ifD
is unlimited=
D
\[,dmax
D;dmax
D] ifD
is limited Fixed point rounding helper functions:down
D :R!D
is a rounding function that rounds towards negative innity.up
D :R!D
is a rounding function that rounds towards positive innity.ISO/IEC CD 10967-2.3:1998(E) Third Committee Draft nearest
D : R !D
is a rounding function that rounds to nearest, ties round to even last digit.The xed point result helper function,
result
D, is likeresult
F, but for a xed point type. It will returnover ow
if the rounded result is not representable:result
D :R(R!D
)!D
[fover ow
gresult
D(x;rnd
)=rnd
(x
) ifrnd
(x
)2D
and (rnd
(x
)6= 0 orx
0)=,
0
ifrnd
(x
) = 0 andx <
0 and ,0
available= 0 if
rnd
(x
) = 0 andx <
0 and ,0
not available=
over ow
ifxin
Randrnd
(x
)62D
F
is a oating point type conforming to LIA-1.D
is a xed point type, it cannot conform to LIA-1, since xed point types are not covered by LIA-1.convert
nearestF!D :F
!D
[f,0 ; over ow
g=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]convert
downF!D :F
!D
[fover ow
g=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]convert
upF!D :F
!D
[f,0 ; over ow
gThird Committee Draft ISO/IEC CD 10967-2.3:1998(E)
=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]NOTES
1 The type D need not be visible in the programming language. D may be a subtype of strings, according to some format. Even so, no type for strings need be present in the programming language.
2 This covers, among other things, \output" of oating point type values, to xed point string formats. E.g. a binding may say thatfloattofixedstring(x, m, n)is bound to convertnearestF(Sm;n(x) where Sm;n is strings of length m, representing xed point values in (LID)scaled(10,n). The binding should also detail how NaNs, signed zeroes and innities are represented in Sm;n, as well as the precise format of the strings representing ordinary values. (Note that if the length of the target string is limited, the conversion may over ow.)
5.4.6 Fixed point to oating point conversions
F
is a oating point type conforming to ISO/IEC 10967-1.D
is a xed point type, it cannot conform to ISO/IEC 10967-1, since xed point types are not covered by ISO/IEC 10967-1.convert
nearestD!F :D
!F
[foating over ow ; under ow
g=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]convert
downD!F :D
!F
[foating over ow ; under ow
g=
invalid
(qNaN
) ifx
is a signalling NaN [sNaN
without notication?]convert
upD!F :D
!F
[foating over ow ; under ow
gISO/IEC CD 10967-2.3:1998(E) Third Committee Draft
= 0 if
x
=,0
and ,0
is not available in the target type= 0 if