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>
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" References consulted:
26 .\" Linux libc source code
27 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
30 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
31 .\" Modified 2002-08-10 Walter Harms
32 .\" (walter.harms@informatik.uni-oldenburg.de)
33 .\" Modified 2003-11-18, 2004-10-05 aeb
35 .TH REMAINDER 3 2009-02-04 "" "Linux Programmer's Manual"
37 drem, dremf, dreml, remainder, remainderf, remainderl \- \
38 floating-point remainder function
43 /* The C99 versions */
44 .BI "double remainder(double " x ", double " y );
45 .BI "float remainderf(float " x ", float " y );
46 .BI "long double remainderl(long double " x ", long double " y );
48 /* Obsolete synonyms */
49 .BI "double drem(double " x ", double " y );
50 .BI "float dremf(float " x ", float " y );
51 .BI "long double dreml(long double " x ", long double " y );
57 Feature Test Macro Requirements for glibc (see
58 .BR feature_test_macros (7)):
63 _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _ISOC99_SOURCE; or
68 _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or
74 _SVID_SOURCE || _BSD_SOURCE
79 function computes the remainder of dividing
84 \fIx\fP\-\fIn\fP*\fIy\fP,
89 rounded to the nearest integer.
90 If the absolute value of
91 \fIx\fP\-\fIn\fP*\fIy\fP
96 These functions are unaffected by the current rounding mode (see
101 function does precisely the same thing.
104 functions return the floating-point remainder,
105 \fIx\fP\-\fIn\fP*\fIy\fP.
106 If the return value is 0, it has the sign of
113 is a NaN, a NaN is returned.
121 a domain error occurs, and
127 .\" FIXME . Instead, glibc gives a domain error even if x is a NaN
131 .\" Interestingly, remquo(3) does not have the same problem.
132 a domain error occurs, and
137 for information on how to determine whether an error has occurred
138 when calling these functions.
140 The following errors can occur:
142 Domain error: \fIx\fP is an infinity and \fIy\fP is not a NaN
146 An invalid floating-point exception
150 These functions do not set
153 .\" FIXME . Is it intentional that these functions do not set errno?
154 .\" They do set errno for the y == 0 case, below.
155 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783
157 Domain error: \fIy\fP is zero\" [XXX see bug above] and \fIx\fP is not a NaN
161 An invalid floating-point exception
171 are specified in C99 and POSIX.1-2001.
184 exist on some systems, such as Tru64 and glibc2.
185 Avoid the use of these functions in favor of
191 remainder(nan(""), 0);
193 returns a NaN, as expected, but wrongly causes a domain error;
194 it should yield a silent NaN.
195 .\" FIXME . this bug occurs as at glibc 2.8.
196 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6779
198 The call "remainder(29.0, 3.0)" returns \-1.