6728f7edc2f41ad24bd8977656169af1ed24b092
[dragonfly.git] / lib / libm / man / ieee.3
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. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     from: @(#)ieee.3        6.4 (Berkeley) 5/6/91
29 .\"     $NetBSD: ieee.3,v 1.19 2003/08/07 16:44:48 agc Exp $
30 .\"     $DragonFly: src/lib/libm/man/ieee.3,v 1.2 2006/02/28 02:25:10 swildner Exp $
31 .\"
32 .Dd February 25, 1994
33 .Dt IEEE 3
34 .Os
35 .Sh NAME
36 .Nm copysign ,
37 .Nm copysignf ,
38 .Nm finite ,
39 .Nm finitef ,
40 .Nm ilogb ,
41 .Nm ilogbf ,
42 .Nm nextafter ,
43 .Nm nextafterf ,
44 .Nm remainder ,
45 .Nm remainderf ,
46 .Nm scalbn ,
47 .Nm scalbnf
48 .Nd functions for IEEE arithmetic
49 .Sh LIBRARY
50 .Lb libm
51 .Sh SYNOPSIS
52 .In math.h
53 .Ft double
54 .Fn copysign "double x" "double y"
55 .Ft float
56 .Fn copysignf "float x" "float y"
57 .Ft int
58 .Fn finite "double x"
59 .Ft int
60 .Fn finitef "float x"
61 .Ft int
62 .Fn ilogb "double x"
63 .Ft int
64 .Fn ilogbf "float x"
65 .Ft double
66 .Fn nextafter "double x" "double y"
67 .Ft float
68 .Fn nextafterf "float x" "float y"
69 .Ft double
70 .Fn remainder "double x" "double y"
71 .Ft float
72 .Fn remainderf "float x" "float y"
73 .Ft double
74 .Fn scalbn "double x" "int n"
75 .Ft float
76 .Fn scalbnf "float x" "int n"
77 .Sh DESCRIPTION
78 These functions are required or recommended by
79 .St -ieee754 .
80 .Pp
81 .Fn copysign
82 returns
83 .Fa x
84 with its sign changed to
85 .Fa y Ns 's .
86 .Pp
87 .Fn finite
88 returns the value 1 just when
89 \-\*(If \*(Lt
90 .Fa x
91 \*(Lt +\*(If;
92 otherwise a
93 zero is returned
94 (when
95 .Pf \\*(Ba Ns Fa x Ns \\*(Ba
96 = \*(If or
97 .Fa x
98 is \*(Na).
99 .Pp
100 .Fn ilogb
101 returns
102 .Fa x Ns 's exponent
103 .Fa n ,
104 in integer format.
105 .Fn ilogb \*(Pm\*(If
106 returns
107 .Dv INT_MAX
108 and
109 .Fn ilogb 0
110 returns
111 .Dv INT_MIN .
112 .Pp
113 .Fn nextafter
114 returns the next machine representable number from
115 .Fa x
116 in direction
117 .Fa y .
118 .Pp
119 .Fn remainder
120 returns the remainder
121 .Fa r
122 :=
123 .Fa x
124 \-
125 .Fa n\(**y
126 where
127 .Fa n
128 is the integer nearest the exact value of
129 .Bk -words
130 .Fa x Ns / Ns Fa y ;
131 .Ek
132 moreover if
133 .Pf \\*(Ba Fa n
134 \-
135 .Sm off
136 .Fa x No / Fa y No \\*(Ba
137 .Sm on
138 =
139 \(12
140 then
141 .Fa n
142 is even.
143 Consequently the remainder is computed exactly and
144 .Sm off
145 .Pf \\*(Ba Fa r No \\*(Ba
146 .Sm on
147 \*(Le
148 .Sm off
149 .Pf \\*(Ba Fa y No \\*(Ba/2 .
150 .Sm on
151 But
152 .Fn remainder x 0
153 and
154 .Fn remainder \*(If 0
155 are invalid operations that produce a \*(Na.
156 .Pp
157 .Fn scalbn
158 returns
159 .Fa x Ns \(**(2** Ns Fa n )
160 computed by exponent manipulation.
161 .Sh SEE ALSO
162 .Xr math 3
163 .Sh STANDARDS
164 .St -ieee754
165 .Sh HISTORY
166 The
167 .Nm ieee
168 functions appeared in
169 .Bx 4.3 .