2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
4 .\" <mtk.manpages@gmail.com>
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
8 .\" References consulted:
9 .\" Linux libc source code
10 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
13 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
14 .\" Modified 2002-08-10 Walter Harms
15 .\" (walter.harms@informatik.uni-oldenburg.de)
16 .\" Modified 2003-11-18, 2004-10-05 aeb
18 .TH remainder 3 (date) "Linux man-pages (unreleased)"
20 drem, dremf, dreml, remainder, remainderf, remainderl \- \
21 floating-point remainder function
24 .RI ( libm ", " \-lm )
29 /* The C99 versions */
30 .BI "double remainder(double " x ", double " y );
31 .BI "float remainderf(float " x ", float " y );
32 .BI "long double remainderl(long double " x ", long double " y );
34 /* Obsolete synonyms */
35 .BI "double drem(double " x ", double " y );
36 .BI "float dremf(float " x ", float " y );
37 .BI "long double dreml(long double " x ", long double " y );
41 Feature Test Macro Requirements for glibc (see
42 .BR feature_test_macros (7)):
47 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
48 || _XOPEN_SOURCE >= 500
49 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
50 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
51 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
57 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
58 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
59 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
66 /* Since glibc 2.19: */ _DEFAULT_SOURCE
67 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
71 functions compute the remainder of dividing
76 \fIx\fP\-\fIn\fP*\fIy\fP,
81 rounded to the nearest integer.
82 If the absolute value of
83 \fIx\fP\-\fIn\fP*\fIy\fP
88 These functions are unaffected by the current rounding mode (see
93 function does precisely the same thing.
96 functions return the floating-point remainder,
97 \fIx\fP\-\fIn\fP*\fIy\fP.
98 If the return value is 0, it has the sign of
105 is a NaN, a NaN is returned.
113 a domain error occurs, and
119 .\" FIXME . Instead, glibc gives a domain error even if x is a NaN
123 .\" Interestingly, remquo(3) does not have the same problem.
124 a domain error occurs, and
129 for information on how to determine whether an error has occurred
130 when calling these functions.
132 The following errors can occur:
134 Domain error: \fIx\fP is an infinity and \fIy\fP is not a NaN
139 An invalid floating-point exception
143 These functions do not set
147 Domain error: \fIy\fP is zero\" [XXX see bug above] and \fIx\fP is not a NaN
151 An invalid floating-point exception
155 For an explanation of the terms used in this section, see
163 Interface Attribute Value
171 T} Thread safety MT-Safe
183 are specified in C99, POSIX.1-2001, and POSIX.1-2008.
196 exist on some systems, such as Tru64 and glibc2.
197 Avoid the use of these functions in favor of
202 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6779
207 remainder(nan(""), 0);
211 returned a NaN, as expected, but wrongly caused a domain error.
212 Since glibc 2.15, a silent NaN (i.e., no domain error) is returned.
215 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783
219 for the domain error that occurs when
225 The call "remainder(29.0, 3.0)" returns \-1.