]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/remainder.3
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man3 / remainder.3
CommitLineData
fea681da 1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
57e4e4d3
MK
2.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3.\" <mtk.manpages@gmail.com>
fea681da 4.\"
5fbde956 5.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
6.\"
7.\" References consulted:
8.\" Linux libc source code
9.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10.\" 386BSD man pages
11.\"
12.\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
c13182ef 13.\" Modified 2002-08-10 Walter Harms
ba283ad2 14.\" (walter.harms@informatik.uni-oldenburg.de)
fea681da
MK
15.\" Modified 2003-11-18, 2004-10-05 aeb
16.\"
4c1c5274 17.TH remainder 3 (date) "Linux man-pages (unreleased)"
fea681da 18.SH NAME
ba283ad2
MK
19drem, dremf, dreml, remainder, remainderf, remainderl \- \
20floating-point remainder function
d21ffca7
AC
21.SH LIBRARY
22Math library
8fc3b2cf 23.RI ( libm ", " \-lm )
fea681da
MK
24.SH SYNOPSIS
25.nf
26.B #include <math.h>
68e4db0a 27.PP
fea681da
MK
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 );
68e4db0a 32.PP
fea681da
MK
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 );
15f0b7af 37.fi
68e4db0a 38.PP
d39ad78f 39.RS -4
cc4615cc
MK
40Feature Test Macro Requirements for glibc (see
41.BR feature_test_macros (7)):
d39ad78f 42.RE
68e4db0a 43.PP
57e4e4d3 44.BR remainder ():
9d2adbae 45.nf
5c10d2c5
MK
46 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
47 || _XOPEN_SOURCE >= 500
48.\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
9d2adbae
MK
49 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
50 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
51.fi
98c9347c 52.PP
cc4615cc
MK
53.BR remainderf (),
54.BR remainderl ():
9d2adbae 55.nf
5c10d2c5 56 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
9d2adbae
MK
57 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
58 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
59.fi
98c9347c 60.PP
cc4615cc 61.BR drem (),
e0bf9127 62.BR dremf (),
cc4615cc 63.BR dreml ():
9d2adbae
MK
64.nf
65 /* Since glibc 2.19: */ _DEFAULT_SOURCE
66 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
67.fi
fea681da 68.SH DESCRIPTION
5600f73a
MK
69These
70functions compute the remainder of dividing
fea681da
MK
71.I x
72by
73.IR y .
74The return value is
57e4e4d3 75\fIx\fP\-\fIn\fP*\fIy\fP,
fea681da
MK
76where
77.I n
78is the value
646b2977 79.IR "x\ /\ y" ,
fea681da 80rounded to the nearest integer.
385cf745 81If the absolute value of
57e4e4d3
MK
82\fIx\fP\-\fIn\fP*\fIy\fP
83is 0.5,
84.I n
85is chosen to be even.
847e0d88 86.PP
5dcc3b66
MK
87These functions are unaffected by the current rounding mode (see
88.BR fenv (3)).
dd3568a1 89.PP
fea681da 90The
63aa9df0 91.BR drem ()
fea681da 92function does precisely the same thing.
47297adb 93.SH RETURN VALUE
57e4e4d3
MK
94On success, these
95functions return the floating-point remainder,
96\fIx\fP\-\fIn\fP*\fIy\fP.
97If the return value is 0, it has the sign of
98.IR x .
847e0d88 99.PP
57e4e4d3
MK
100If
101.I x
102or
fea681da 103.I y
57e4e4d3 104is a NaN, a NaN is returned.
847e0d88 105.PP
57e4e4d3
MK
106If
107.I x
385cf745 108is an infinity,
57e4e4d3
MK
109and
110.I y
111is not a NaN,
efe294cb 112a domain error occurs, and
57e4e4d3 113a NaN is returned.
847e0d88 114.PP
57e4e4d3
MK
115If
116.I y
117is zero,
118.\" FIXME . Instead, glibc gives a domain error even if x is a NaN
119and
120.I x
121is not a NaN,
122.\" Interestingly, remquo(3) does not have the same problem.
efe294cb 123a domain error occurs, and
57e4e4d3 124a NaN is returned.
fea681da 125.SH ERRORS
57e4e4d3
MK
126See
127.BR math_error (7)
128for information on how to determine whether an error has occurred
129when calling these functions.
130.PP
131The following errors can occur:
fea681da 132.TP
57e4e4d3 133Domain error: \fIx\fP is an infinity and \fIy\fP is not a NaN
f5a9a204
MK
134.I errno
135is set to
1ae6b2c7 136.B EDOM
f5a9a204 137(but see BUGS).
57e4e4d3
MK
138An invalid floating-point exception
139.RB ( FE_INVALID )
140is raised.
141.IP
142These functions do not set
1ae6b2c7 143.I errno
57e4e4d3 144for this case.
57e4e4d3
MK
145.TP
146Domain error: \fIy\fP is zero\" [XXX see bug above] and \fIx\fP is not a NaN
147.I errno
148is set to
149.BR EDOM .
150An invalid floating-point exception
151.RB ( FE_INVALID )
152is raised.
8f980415
MS
153.SH ATTRIBUTES
154For an explanation of the terms used in this section, see
155.BR attributes (7).
c466875e
MK
156.ad l
157.nh
8f980415
MS
158.TS
159allbox;
c466875e 160lbx lb lb
8f980415
MS
161l l l.
162Interface Attribute Value
163T{
164.BR drem (),
165.BR dremf (),
166.BR dreml (),
8f980415
MS
167.BR remainder (),
168.BR remainderf (),
8f980415
MS
169.BR remainderl ()
170T} Thread safety MT-Safe
171.TE
c466875e
MK
172.hy
173.ad
174.sp 1
3113c7f3 175.SH STANDARDS
57e4e4d3 176.\" IEC 60559.
c13182ef
MK
177The functions
178.BR remainder (),
179.BR remainderf (),
180and
f87925c6 181.BR remainderl ()
9a0216ac 182are specified in C99, POSIX.1-2001, and POSIX.1-2008.
847e0d88 183.PP
fea681da 184The function
63aa9df0 185.BR drem ()
1c44bd5b
MK
186is from 4.3BSD.
187The
9d9dc1e8
MK
188.I float
189and
190.I "long double"
c13182ef 191variants
63aa9df0 192.BR dremf ()
fea681da 193and
63aa9df0 194.BR dreml ()
fea681da 195exist on some systems, such as Tru64 and glibc2.
aababe28
MK
196Avoid the use of these functions in favor of
197.BR remainder ()
198etc.
57e4e4d3 199.SH BUGS
2e8302fc
MK
200Before glibc 2.15,
201.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6779
202the call
847e0d88 203.PP
1ae6b2c7
AC
204.in +4n
205.EX
206remainder(nan(""), 0);
207.EE
208.in
847e0d88 209.PP
2e8302fc
MK
210returned a NaN, as expected, but wrongly caused a domain error.
211Since glibc 2.15, a silent NaN (i.e., no domain error) is returned.
847e0d88 212.PP
f5a9a204
MK
213Before glibc 2.15,
214.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783
215.I errno
216was not set to
1ae6b2c7 217.B EDOM
f5a9a204
MK
218for the domain error that occurs when
219.I x
220is an infinity and
221.I y
222is not a NaN.
a14af333 223.SH EXAMPLES
3e807a31 224The call "remainder(29.0, 3.0)" returns \-1.
47297adb 225.SH SEE ALSO
b1e10d40 226.BR div (3),
ba283ad2
MK
227.BR fmod (3),
228.BR remquo (3)