xref: /freebsd/lib/msun/man/ieee.3 (revision 17ee9d00bc1ae1e598c38f25826f861e4bc6c3ce)
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.\"	$Id: ieee.3,v 1.7 1994/03/10 18:15:07 jtc Exp $
34.\"
35.Dd Feb 25, 1994
36.Dt IEEE 3
37.Os
38.Sh NAME
39.Nm copysign ,
40.Nm finite ,
41.Nm ilogb ,
42.Nm nextafter ,
43.Nm remainder ,
44.Nm scalbn
45.Nd Functions for IEEE arithmetic
46.Sh SYNOPSIS
47.Fd #include <math.h>
48.Ft double
49.Fn copysign "double x" "double y"
50.Ft int
51.Fn finite "double x"
52.Ft int
53.Fn ilogb "double x"
54.Ft double
55.Fn nextafter "double x" "double y"
56.Ft double
57.Fn remainder "double x" "double y"
58.Ft double
59.Fn scalbn "double x" "int n"
60.Sh DESCRIPTION
61These functions are required or recommended by
62.St -ieee754 .
63.Pp
64.Fn copysign
65returns
66.Fa x
67with its sign changed to
68.Fa y Ns 's.
69.Pp
70.Fn finite
71returns the value 1 just when
72\-\*(If \*(Lt
73.Fa x
74\*(Lt +\*(If;
75otherwise a
76zero is returned
77(when
78.Pf \\*(Ba Ns Fa x Ns \\*(Ba
79= \*(If or
80.Fa x
81is \*(Na
82.Pp
83.Fn ilogb
84returns
85.Fa x Ns 's exponent
86.Fa n ,
87in integer format.
88.Fn ilogb \*(Pm\*(If
89returns
90.Dv INT_MAX
91and
92.Fn ilogb 0
93returns
94.Dv INT_MIN .
95.Pp
96.Fn nextafter
97returns the next machine representable number from
98.Fa x
99in direction
100.Fa y .
101.Pp
102.Fn remainder
103returns the remainder
104.Fa r
105:=
106.Fa x
107\-
108.Fa n\(**y
109where
110.Fa n
111is the integer nearest the exact value of
112.Bk -words
113.Fa x Ns / Ns Fa y ;
114.Ek
115moreover if
116.Pf \\*(Ba Fa n
117\-
118.Sm off
119.Fa x No / Fa y No \\*(Ba
120.Sm on
121=
1221/2
123then
124.Fa n
125is even.  Consequently
126the remainder is computed exactly and
127.Sm off
128.Pf \\*(Ba Fa r No \\*(Ba
129.Sm on
130\*(Le
131.Sm off
132.Pf \\*(Ba Fa y No \\*(Ba/2.
133.Sm on
134But
135.Fn remainder x 0
136and
137.Fn remainder \*(If 0
138are invalid operations that produce a \*(Na.
139.Pp
140.Fn scalbn
141returns
142.Fa x Ns \(**(2** Ns Fa n )
143computed by exponent manipulation.
144.Sh SEE ALSO
145.Xr math 3
146.Sh HISTORY
147The
148.Nm ieee
149functions appeared in
150.Bx 4.3 .
151.Sh STANDARDS
152.St -ieee754
153