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 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\" References consulted:
8 .\" Linux libc source code
9 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
12 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
13 .\" Modified 2002-08-10 Walter Harms
14 .\" (walter.harms@informatik.uni-oldenburg.de)
15 .\" Modified 2003-11-18, 2004-10-05 aeb
17 .TH REMAINDER 3 2021-03-22 GNU "Linux Programmer's Manual"
19 drem, dremf, dreml, remainder, remainderf, remainderl \- \
20 floating-point remainder function
23 .RI ( libm ", " \-lm )
28 /* The C99 versions */
29 .BI "double remainder(double " x ", double " y );
30 .BI "float remainderf(float " x ", float " y );
31 .BI "long double remainderl(long double " x ", long double " y );
33 /* Obsolete synonyms */
34 .BI "double drem(double " x ", double " y );
35 .BI "float dremf(float " x ", float " y );
36 .BI "long double dreml(long double " x ", long double " y );
40 Feature Test Macro Requirements for glibc (see
41 .BR feature_test_macros (7)):
46 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
47 || _XOPEN_SOURCE >= 500
48 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
49 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
50 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
56 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
57 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
58 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
65 /* Since glibc 2.19: */ _DEFAULT_SOURCE
66 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
70 functions compute the remainder of dividing
75 \fIx\fP\-\fIn\fP*\fIy\fP,
80 rounded to the nearest integer.
81 If the absolute value of
82 \fIx\fP\-\fIn\fP*\fIy\fP
87 These functions are unaffected by the current rounding mode (see
92 function does precisely the same thing.
95 functions return the floating-point remainder,
96 \fIx\fP\-\fIn\fP*\fIy\fP.
97 If the return value is 0, it has the sign of
104 is a NaN, a NaN is returned.
112 a domain error occurs, and
118 .\" FIXME . Instead, glibc gives a domain error even if x is a NaN
122 .\" Interestingly, remquo(3) does not have the same problem.
123 a domain error occurs, and
128 for information on how to determine whether an error has occurred
129 when calling these functions.
131 The following errors can occur:
133 Domain error: \fIx\fP is an infinity and \fIy\fP is not a NaN
138 An invalid floating-point exception
142 These functions do not set
146 Domain error: \fIy\fP is zero\" [XXX see bug above] and \fIx\fP is not a NaN
150 An invalid floating-point exception
154 For an explanation of the terms used in this section, see
162 Interface Attribute Value
170 T} Thread safety MT-Safe
182 are specified in C99, POSIX.1-2001, and POSIX.1-2008.
195 exist on some systems, such as Tru64 and glibc2.
196 Avoid the use of these functions in favor of
201 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6779
206 remainder(nan(""), 0);
210 returned a NaN, as expected, but wrongly caused a domain error.
211 Since glibc 2.15, a silent NaN (i.e., no domain error) is returned.
214 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783
218 for the domain error that occurs when
224 The call "remainder(29.0, 3.0)" returns \-1.