xref: /freebsd/lib/msun/man/ieee.3 (revision ba54cdcdda639bebc917b1796ecbc35a83ff8625)
1.\" Copyright (c) 1985, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     from: @(#)ieee.3	6.4 (Berkeley) 5/6/91
33.\" $FreeBSD$
34.\"
35.Dd June 20, 2004
36.Dt IEEE 3
37.Os
38.Sh NAME
39.Nm copysign ,
40.Nm copysignf ,
41.Nm copysignl ,
42.Nm finite ,
43.Nm finitef ,
44.Nm ilogb ,
45.Nm ilogbf ,
46.Nm ilogbl ,
47.Nm nextafter ,
48.Nm nextafterf ,
49.Nm remainder ,
50.Nm remainderf ,
51.Nm scalbln ,
52.Nm scalblnf ,
53.Nm scalbn ,
54.Nm scalbnf
55.Nd functions for IEEE arithmetic
56.Sh LIBRARY
57.Lb libm
58.Sh SYNOPSIS
59.In math.h
60.Ft double
61.Fn copysign "double x" "double y"
62.Ft float
63.Fn copysignf "float x" "float y"
64.Ft long double
65.Fn copysignl "long double x" "long double y"
66.Ft int
67.Fn finite "double x"
68.Ft int
69.Fn finitef "float x"
70.Ft int
71.Fn ilogb "double x"
72.Ft int
73.Fn ilogbf "float x"
74.Ft int
75.Fn ilogbl "long double x"
76.Ft double
77.Fn nextafter "double x" "double y"
78.Ft float
79.Fn nextafterf "float x" "float y"
80.Ft double
81.Fn remainder "double x" "double y"
82.Ft float
83.Fn remainderf "float x" "float y"
84.Ft double
85.Fn scalbln "double x" "long n"
86.Ft float
87.Fn scalblnf "float x" "long n"
88.Ft double
89.Fn scalbn "double x" "int n"
90.Ft float
91.Fn scalbnf "float x" "int n"
92.Sh DESCRIPTION
93These functions are required or recommended by
94.St -ieee754 .
95.Pp
96The
97.Fn copysign ,
98.Fn copysignf
99and
100.Fn copysignl
101functions
102return
103.Fa x
104with its sign changed to
105.Fa y Ns 's .
106.Pp
107.Fn finite
108and
109.Fn finitef
110return the value 1 just when
111\-\*(If \*(Lt
112.Fa x
113\*(Lt +\*(If;
114otherwise a
115zero is returned
116(when
117.Pf \\*(Ba Ns Fa x Ns \\*(Ba
118= \*(If or
119.Fa x
120is \*(Na).
121.Pp
122.Fn ilogb ,
123.Fn ilogbf
124and
125.Fn ilogbl
126return
127.Fa x Ns 's exponent,
128in integer format.
129.Fn ilogb \*(Pm\*(If
130returns
131.Dv INT_MAX ,
132.Fn ilogb \*(Pm\*(Na
133returns
134.Dv FP_ILOGBNAN
135and
136.Fn ilogb 0
137returns
138.Dv FP_ILOGB0 .
139.Pp
140.Fn nextafter
141and
142.Fn nextafterf
143return the next machine representable number from
144.Fa x
145in direction
146.Fa y .
147.Pp
148.Fn remainder
149and
150.Fn remainderf
151return the remainder
152.Fa r
153:=
154.Fa x
155\-
156.Fa n\(**y
157where
158.Fa n
159is the integer nearest the exact value of
160.Bk -words
161.Fa x Ns / Ns Fa y ;
162.Ek
163moreover if
164.Pf \\*(Ba Fa n
165\-
166.Sm off
167.Fa x No / Fa y No \\*(Ba
168.Sm on
169=
1701/2
171then
172.Fa n
173is even.
174Consequently
175the remainder is computed exactly and
176.Sm off
177.Pf \\*(Ba Fa r No \\*(Ba
178.Sm on
179\*(Le
180.Sm off
181.Pf \\*(Ba Fa y No \\*(Ba/2 .
182.Sm on
183But
184.Fn remainder x 0
185and
186.Fn remainder \*(If 0
187are invalid operations that produce a \*(Na.
188.Pp
189.Fn scalbln ,
190.Fn scalblnf ,
191.Fn scalbn ,
192and
193.Fn scalbnf
194return
195.Fa x Ns \(**(2** Ns Fa n )
196computed by exponent manipulation.
197.Sh SEE ALSO
198.Xr math 3
199.Sh HISTORY
200The
201.Nm ieee
202functions appeared in
203.Bx 4.3 .
204The
205.Fn copysignl ,
206.Fn scalbln ,
207and
208.Fn scalblnf
209functions first appeared in
210.Fx 5.3 .
211.Sh STANDARDS
212.St -ieee754
213