]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
57e4e4d3 MK |
2 | .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
3 | .\" <mtk.manpages@gmail.com> | |
fea681da | 4 | .\" |
93015253 | 5 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
6 | .\" Permission is granted to make and distribute verbatim copies of this |
7 | .\" manual provided the copyright notice and this permission notice are | |
8 | .\" preserved on all copies. | |
9 | .\" | |
10 | .\" Permission is granted to copy and distribute modified versions of this | |
11 | .\" manual under the conditions for verbatim copying, provided that the | |
12 | .\" entire resulting derived work is distributed under the terms of a | |
13 | .\" permission notice identical to this one. | |
c13182ef | 14 | .\" |
fea681da MK |
15 | .\" Since the Linux kernel and libraries are constantly changing, this |
16 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
17 | .\" responsibility for errors or omissions, or for damages resulting from | |
18 | .\" the use of the information contained herein. The author(s) may not | |
19 | .\" have taken the same level of care in the production of this manual, | |
20 | .\" which is licensed free of charge, as they might when working | |
21 | .\" professionally. | |
c13182ef | 22 | .\" |
fea681da MK |
23 | .\" Formatted or processed versions of this manual, if unaccompanied by |
24 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 25 | .\" %%%LICENSE_END |
fea681da MK |
26 | .\" |
27 | .\" References consulted: | |
28 | .\" Linux libc source code | |
29 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
30 | .\" 386BSD man pages | |
31 | .\" | |
32 | .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu) | |
c13182ef | 33 | .\" Modified 2002-08-10 Walter Harms |
ba283ad2 | 34 | .\" (walter.harms@informatik.uni-oldenburg.de) |
fea681da MK |
35 | .\" Modified 2003-11-18, 2004-10-05 aeb |
36 | .\" | |
97986708 | 37 | .TH REMAINDER 3 2016-03-15 "" "Linux Programmer's Manual" |
fea681da | 38 | .SH NAME |
ba283ad2 MK |
39 | drem, dremf, dreml, remainder, remainderf, remainderl \- \ |
40 | floating-point remainder function | |
fea681da MK |
41 | .SH SYNOPSIS |
42 | .nf | |
43 | .B #include <math.h> | |
44 | .sp | |
45 | /* The C99 versions */ | |
46 | .BI "double remainder(double " x ", double " y ); | |
47 | .BI "float remainderf(float " x ", float " y ); | |
48 | .BI "long double remainderl(long double " x ", long double " y ); | |
49 | .sp | |
50 | /* Obsolete synonyms */ | |
51 | .BI "double drem(double " x ", double " y ); | |
52 | .BI "float dremf(float " x ", float " y ); | |
53 | .BI "long double dreml(long double " x ", long double " y ); | |
54 | .sp | |
55 | .fi | |
20c58d70 | 56 | Link with \fI\-lm\fP. |
cc4615cc MK |
57 | .sp |
58 | .in -4n | |
59 | Feature Test Macro Requirements for glibc (see | |
60 | .BR feature_test_macros (7)): | |
61 | .in | |
62 | .sp | |
63 | .ad l | |
57e4e4d3 | 64 | .BR remainder (): |
1d8e7622 | 65 | .RS 4 |
636ed4d5 MK |
66 | _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L |
67 | || _XOPEN_SOURCE\ >=\ 500 | |
68 | .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED | |
69 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE | |
70 | || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
1d8e7622 | 71 | .RE |
57e4e4d3 | 72 | .br |
cc4615cc MK |
73 | .BR remainderf (), |
74 | .BR remainderl (): | |
1d8e7622 | 75 | .RS 4 |
636ed4d5 MK |
76 | _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L |
77 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE | |
78 | || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
1d8e7622 | 79 | .RE |
cc4615cc MK |
80 | .br |
81 | .BR drem (), | |
e0bf9127 | 82 | .BR dremf (), |
cc4615cc | 83 | .BR dreml (): |
1d8e7622 | 84 | .RS 4 |
636ed4d5 MK |
85 | /* Since glibc 2.19: */ _DEFAULT_SOURCE |
86 | || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
1d8e7622 | 87 | .RE |
cc4615cc | 88 | .ad b |
fea681da | 89 | .SH DESCRIPTION |
5600f73a MK |
90 | These |
91 | functions compute the remainder of dividing | |
fea681da MK |
92 | .I x |
93 | by | |
94 | .IR y . | |
95 | The return value is | |
57e4e4d3 | 96 | \fIx\fP\-\fIn\fP*\fIy\fP, |
fea681da MK |
97 | where |
98 | .I n | |
99 | is the value | |
646b2977 | 100 | .IR "x\ /\ y" , |
fea681da | 101 | rounded to the nearest integer. |
385cf745 | 102 | If the absolute value of |
57e4e4d3 MK |
103 | \fIx\fP\-\fIn\fP*\fIy\fP |
104 | is 0.5, | |
105 | .I n | |
106 | is chosen to be even. | |
107 | ||
5dcc3b66 MK |
108 | These functions are unaffected by the current rounding mode (see |
109 | .BR fenv (3)). | |
fea681da MK |
110 | .LP |
111 | The | |
63aa9df0 | 112 | .BR drem () |
fea681da | 113 | function does precisely the same thing. |
47297adb | 114 | .SH RETURN VALUE |
57e4e4d3 MK |
115 | On success, these |
116 | functions return the floating-point remainder, | |
117 | \fIx\fP\-\fIn\fP*\fIy\fP. | |
118 | If the return value is 0, it has the sign of | |
119 | .IR x . | |
120 | ||
121 | If | |
122 | .I x | |
123 | or | |
fea681da | 124 | .I y |
57e4e4d3 MK |
125 | is a NaN, a NaN is returned. |
126 | ||
127 | If | |
128 | .I x | |
385cf745 | 129 | is an infinity, |
57e4e4d3 MK |
130 | and |
131 | .I y | |
132 | is not a NaN, | |
efe294cb | 133 | a domain error occurs, and |
57e4e4d3 MK |
134 | a NaN is returned. |
135 | ||
136 | If | |
137 | .I y | |
138 | is zero, | |
139 | .\" FIXME . Instead, glibc gives a domain error even if x is a NaN | |
140 | and | |
141 | .I x | |
142 | is not a NaN, | |
143 | .\" Interestingly, remquo(3) does not have the same problem. | |
efe294cb | 144 | a domain error occurs, and |
57e4e4d3 | 145 | a NaN is returned. |
fea681da | 146 | .SH ERRORS |
57e4e4d3 MK |
147 | See |
148 | .BR math_error (7) | |
149 | for information on how to determine whether an error has occurred | |
150 | when calling these functions. | |
151 | .PP | |
152 | The following errors can occur: | |
fea681da | 153 | .TP |
57e4e4d3 MK |
154 | Domain error: \fIx\fP is an infinity and \fIy\fP is not a NaN |
155 | .\" .I errno | |
156 | .\" is set to | |
157 | .\" .BR EDOM . | |
158 | An invalid floating-point exception | |
159 | .RB ( FE_INVALID ) | |
160 | is raised. | |
161 | .IP | |
162 | These functions do not set | |
163 | .IR errno | |
164 | for this case. | |
165 | .\" FIXME . Is it intentional that these functions do not set errno? | |
166 | .\" They do set errno for the y == 0 case, below. | |
167 | .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783 | |
168 | .TP | |
169 | Domain error: \fIy\fP is zero\" [XXX see bug above] and \fIx\fP is not a NaN | |
170 | .I errno | |
171 | is set to | |
172 | .BR EDOM . | |
173 | An invalid floating-point exception | |
174 | .RB ( FE_INVALID ) | |
175 | is raised. | |
8f980415 MS |
176 | .SH ATTRIBUTES |
177 | For an explanation of the terms used in this section, see | |
178 | .BR attributes (7). | |
179 | .TS | |
180 | allbox; | |
181 | lbw26 lb lb | |
182 | l l l. | |
183 | Interface Attribute Value | |
184 | T{ | |
185 | .BR drem (), | |
186 | .BR dremf (), | |
187 | .BR dreml (), | |
188 | .br | |
189 | .BR remainder (), | |
190 | .BR remainderf (), | |
191 | .br | |
192 | .BR remainderl () | |
193 | T} Thread safety MT-Safe | |
194 | .TE | |
47297adb | 195 | .SH CONFORMING TO |
57e4e4d3 | 196 | .\" IEC 60559. |
c13182ef MK |
197 | The functions |
198 | .BR remainder (), | |
199 | .BR remainderf (), | |
200 | and | |
f87925c6 | 201 | .BR remainderl () |
9a0216ac | 202 | are specified in C99, POSIX.1-2001, and POSIX.1-2008. |
aababe28 | 203 | |
fea681da | 204 | The function |
63aa9df0 | 205 | .BR drem () |
1c44bd5b MK |
206 | is from 4.3BSD. |
207 | The | |
9d9dc1e8 MK |
208 | .I float |
209 | and | |
210 | .I "long double" | |
c13182ef | 211 | variants |
63aa9df0 | 212 | .BR dremf () |
fea681da | 213 | and |
63aa9df0 | 214 | .BR dreml () |
fea681da | 215 | exist on some systems, such as Tru64 and glibc2. |
aababe28 MK |
216 | Avoid the use of these functions in favor of |
217 | .BR remainder () | |
218 | etc. | |
57e4e4d3 MK |
219 | .SH BUGS |
220 | The call | |
221 | ||
222 | remainder(nan(""), 0); | |
223 | ||
224 | returns a NaN, as expected, but wrongly causes a domain error; | |
225 | it should yield a silent NaN. | |
226 | .\" FIXME . this bug occurs as at glibc 2.8. | |
227 | .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6779 | |
3e807a31 MK |
228 | .SH EXAMPLE |
229 | The call "remainder(29.0, 3.0)" returns \-1. | |
47297adb | 230 | .SH SEE ALSO |
b1e10d40 | 231 | .BR div (3), |
ba283ad2 MK |
232 | .BR fmod (3), |
233 | .BR remquo (3) |