mount_setattr.2: ffix
[man-pages.git] / man3 / remainder.3
blobf828331f504b93c056c4c934a944482813bbab4c
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
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.
14 .\"
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.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
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)
33 .\" Modified 2002-08-10 Walter Harms
34 .\"     (walter.harms@informatik.uni-oldenburg.de)
35 .\" Modified 2003-11-18, 2004-10-05 aeb
36 .\"
37 .TH REMAINDER 3 2021-03-22 "" "Linux Programmer's Manual"
38 .SH NAME
39 drem, dremf, dreml, remainder, remainderf, remainderl \- \
40 floating-point remainder function
41 .SH SYNOPSIS
42 .nf
43 .B #include <math.h>
44 .PP
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 .PP
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 .PP
55 .fi
56 Link with \fI\-lm\fP.
57 .PP
58 .RS -4
59 Feature Test Macro Requirements for glibc (see
60 .BR feature_test_macros (7)):
61 .RE
62 .PP
63 .BR remainder ():
64 .nf
65     _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
66         || _XOPEN_SOURCE >= 500
67 .\"    || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
68         || /* Since glibc 2.19: */ _DEFAULT_SOURCE
69         || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
70 .fi
71 .PP
72 .BR remainderf (),
73 .BR remainderl ():
74 .nf
75     _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
76         || /* Since glibc 2.19: */ _DEFAULT_SOURCE
77         || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
78 .fi
79 .PP
80 .BR drem (),
81 .BR dremf (),
82 .BR dreml ():
83 .nf
84     /* Since glibc 2.19: */ _DEFAULT_SOURCE
85         || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
86 .fi
87 .SH DESCRIPTION
88 These
89 functions compute the remainder of dividing
90 .I x
92 .IR y .
93 The return value is
94 \fIx\fP\-\fIn\fP*\fIy\fP,
95 where
96 .I n
97 is the value
98 .IR "x\ /\ y" ,
99 rounded to the nearest integer.
100 If the absolute value of
101 \fIx\fP\-\fIn\fP*\fIy\fP
102 is 0.5,
103 .I n
104 is chosen to be even.
106 These functions are unaffected by the current rounding mode (see
107 .BR fenv (3)).
110 .BR drem ()
111 function does precisely the same thing.
112 .SH RETURN VALUE
113 On success, these
114 functions return the floating-point remainder,
115 \fIx\fP\-\fIn\fP*\fIy\fP.
116 If the return value is 0, it has the sign of
117 .IR x .
120 .I x
122 .I y
123 is a NaN, a NaN is returned.
126 .I x
127 is an infinity,
129 .I y
130 is not a NaN,
131 a domain error occurs, and
132 a NaN is returned.
135 .I y
136 is zero,
137 .\" FIXME . Instead, glibc gives a domain error even if x is a NaN
139 .I x
140 is not a NaN,
141 .\" Interestingly, remquo(3) does not have the same problem.
142 a domain error occurs, and
143 a NaN is returned.
144 .SH ERRORS
146 .BR math_error (7)
147 for information on how to determine whether an error has occurred
148 when calling these functions.
150 The following errors can occur:
152 Domain error: \fIx\fP is an infinity and \fIy\fP is not a NaN
153 .I errno
154 is set to
155 .BR EDOM
156 (but see BUGS).
157 An invalid floating-point exception
158 .RB ( FE_INVALID )
159 is raised.
161 These functions do not set
162 .IR errno
163 for this case.
165 Domain error: \fIy\fP is zero\" [XXX see bug above] and \fIx\fP is not a NaN
166 .I errno
167 is set to
168 .BR EDOM .
169 An invalid floating-point exception
170 .RB ( FE_INVALID )
171 is raised.
172 .SH ATTRIBUTES
173 For an explanation of the terms used in this section, see
174 .BR attributes (7).
175 .ad l
178 allbox;
179 lbx lb lb
180 l l l.
181 Interface       Attribute       Value
183 .BR drem (),
184 .BR dremf (),
185 .BR dreml (),
186 .BR remainder (),
187 .BR remainderf (),
188 .BR remainderl ()
189 T}      Thread safety   MT-Safe
193 .sp 1
194 .SH CONFORMING TO
195 .\" IEC 60559.
196 The functions
197 .BR remainder (),
198 .BR remainderf (),
200 .BR remainderl ()
201 are specified in C99, POSIX.1-2001, and POSIX.1-2008.
203 The function
204 .BR drem ()
205 is from 4.3BSD.
207 .I float
209 .I "long double"
210 variants
211 .BR dremf ()
213 .BR dreml ()
214 exist on some systems, such as Tru64 and glibc2.
215 Avoid the use of these functions in favor of
216 .BR remainder ()
217 etc.
218 .SH BUGS
219 Before glibc 2.15,
220 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6779
221 the call
223     remainder(nan(""), 0);
225 returned a NaN, as expected, but wrongly caused a domain error.
226 Since glibc 2.15, a silent NaN (i.e., no domain error) is returned.
228 Before glibc 2.15,
229 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783
230 .I errno
231 was not set to
232 .BR EDOM
233 for the domain error that occurs when
234 .I x
235 is an infinity and
236 .I y
237 is not a NaN.
238 .SH EXAMPLES
239 The call "remainder(29.0, 3.0)" returns \-1.
240 .SH SEE ALSO
241 .BR div (3),
242 .BR fmod (3),
243 .BR remquo (3)