xref: /freebsd/lib/msun/man/ieee.3 (revision 2357939bc239bd5334a169b62313806178dd8f30)
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 February 25, 1994
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 nextafter ,
47.Nm nextafterf ,
48.Nm remainder ,
49.Nm remainderf ,
50.Nm scalbn ,
51.Nm scalbnf
52.Nd functions for IEEE arithmetic
53.Sh LIBRARY
54.Lb libm
55.Sh SYNOPSIS
56.In math.h
57.Ft double
58.Fn copysign "double x" "double y"
59.Ft float
60.Fn copysignf "float x" "float y"
61.Ft long double
62.Fn copysignl "long double x" "long double y"
63.Ft int
64.Fn finite "double x"
65.Ft int
66.Fn finitef "float x"
67.Ft int
68.Fn ilogb "double x"
69.Ft int
70.Fn ilogbf "float x"
71.Ft double
72.Fn nextafter "double x" "double y"
73.Ft float
74.Fn nextafterf "float x" "float y"
75.Ft double
76.Fn remainder "double x" "double y"
77.Ft float
78.Fn remainderf "float x" "float y"
79.Ft double
80.Fn scalbn "double x" "int n"
81.Ft float
82.Fn scalbnf "float x" "int n"
83.Sh DESCRIPTION
84These functions are required or recommended by
85.St -ieee754 .
86.Pp
87.Fn copysign ,
88.Fn copysignf
89and
90.Fn copysignl
91return
92.Fa x
93with its sign changed to
94.Fa y Ns 's .
95.Pp
96.Fn finite
97and
98.Fn finitef
99return the value 1 just when
100\-\*(If \*(Lt
101.Fa x
102\*(Lt +\*(If;
103otherwise a
104zero is returned
105(when
106.Pf \\*(Ba Ns Fa x Ns \\*(Ba
107= \*(If or
108.Fa x
109is \*(Na).
110.Pp
111.Fn ilogb
112and
113.Fn ilogbf
114return
115.Fa x Ns 's exponent,
116in integer format.
117.Fn ilogb \*(Pm\*(If
118returns
119.Dv INT_MAX
120and
121.Fn ilogb 0
122returns
123.Dv INT_MIN .
124.Pp
125.Fn nextafter
126and
127.Fn nextafterf
128return the next machine representable number from
129.Fa x
130in direction
131.Fa y .
132.Pp
133.Fn remainder
134and
135.Fn remainderf
136return the remainder
137.Fa r
138:=
139.Fa x
140\-
141.Fa n\(**y
142where
143.Fa n
144is the integer nearest the exact value of
145.Bk -words
146.Fa x Ns / Ns Fa y ;
147.Ek
148moreover if
149.Pf \\*(Ba Fa n
150\-
151.Sm off
152.Fa x No / Fa y No \\*(Ba
153.Sm on
154=
1551/2
156then
157.Fa n
158is even.  Consequently
159the remainder is computed exactly and
160.Sm off
161.Pf \\*(Ba Fa r No \\*(Ba
162.Sm on
163\*(Le
164.Sm off
165.Pf \\*(Ba Fa y No \\*(Ba/2 .
166.Sm on
167But
168.Fn remainder x 0
169and
170.Fn remainder \*(If 0
171are invalid operations that produce a \*(Na.
172.Pp
173.Fn scalbn
174and
175.Fn scalbnf
176return
177.Fa x Ns \(**(2** Ns Fa n )
178computed by exponent manipulation.
179.Sh SEE ALSO
180.Xr math 3
181.Sh HISTORY
182The
183.Nm ieee
184functions appeared in
185.Bx 4.3 .
186The
187.Fn copysignl
188function first appeared in
189.Fx 5.3 .
190.Sh STANDARDS
191.St -ieee754
192