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 2008-08-05 "" "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.
100 function does precisely the same thing.
103 functions return the floating-point remainder,
104 \fIx\fP\-\fIn\fP*\fIy\fP.
105 If the return value is 0, it has the sign of
112 is a NaN, a NaN is returned.
120 a domain error occurs, and
126 .\" FIXME . Instead, glibc gives a domain error even if x is a NaN
130 .\" Interestingly, remquo(3) does not have the same problem.
131 a domain error occurs, and
136 for information on how to determine whether an error has occurred
137 when calling these functions.
139 The following errors can occur:
141 Domain error: \fIx\fP is an infinity and \fIy\fP is not a NaN
145 An invalid floating-point exception
149 These functions do not set
152 .\" FIXME . Is it intentional that these functions do not set errno?
153 .\" They do set errno for the y == 0 case, below.
154 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783
156 Domain error: \fIy\fP is zero\" [XXX see bug above] and \fIx\fP is not a NaN
160 An invalid floating-point exception
170 are specified in C99 and POSIX.1-2001.
183 exist on some systems, such as Tru64 and glibc2.
184 Avoid the use of these functions in favor of
190 remainder(nan(""), 0);
192 returns a NaN, as expected, but wrongly causes a domain error;
193 it should yield a silent NaN.
194 .\" FIXME . this bug occurs as at glibc 2.8.
195 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6779
197 The call "remainder(29.0, 3.0)" returns \-1.