]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/remainder.3
ffix
[thirdparty/man-pages.git] / man3 / remainder.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\" 386BSD man pages
27 .\"
28 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
29 .\" Modified 2002-08-10 Walter Harms
30 .\" (walter.harms@informatik.uni-oldenburg.de)
31 .\" Modified 2003-11-18, 2004-10-05 aeb
32 .\"
33 .TH REMAINDER 3 2007-07-26 "" "Linux Programmer's Manual"
34 .SH NAME
35 drem, dremf, dreml, remainder, remainderf, remainderl \- \
36 floating-point remainder function
37 .SH SYNOPSIS
38 .nf
39 .B #include <math.h>
40 .sp
41 /* The C99 versions */
42 .BI "double remainder(double " x ", double " y );
43 .BI "float remainderf(float " x ", float " y );
44 .BI "long double remainderl(long double " x ", long double " y );
45 .sp
46 /* Obsolete synonyms */
47 .BI "double drem(double " x ", double " y );
48 .BI "float dremf(float " x ", float " y );
49 .BI "long double dreml(long double " x ", long double " y );
50 .sp
51 .fi
52 Link with \fI\-lm\fP.
53 .sp
54 .in -4n
55 Feature Test Macro Requirements for glibc (see
56 .BR feature_test_macros (7)):
57 .in
58 .sp
59 .ad l
60 .BR remainder (),
61 .BR remainderf (),
62 .BR remainderl ():
63 _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _ISOC99_SOURCE; or
64 .I cc\ -std=c99
65 .br
66 .BR drem (),
67 .BR dremf (),
68 .BR dreml ():
69 _SVID_SOURCE || _BSD_SOURCE
70 .ad b
71 .SH DESCRIPTION
72 The
73 .BR remainder ()
74 function computes the remainder of dividing
75 .I x
76 by
77 .IR y .
78 The return value is
79 .IR x " \- " n " * " y ,
80 where
81 .I n
82 is the value
83 .IR x " / " y ,
84 rounded to the nearest integer.
85 If this quotient is 1/2 (mod 1), it is rounded to the nearest even number
86 (independent of the current rounding mode).
87 If the return value is 0, it has the sign of
88 .IR x .
89 .LP
90 The
91 .BR drem ()
92 function does precisely the same thing.
93 .SH "RETURN VALUE"
94 The
95 .BR remainder ()
96 function returns the remainder, unless
97 .I y
98 is zero, when the function fails and
99 .I errno
100 is set.
101 .SH ERRORS
102 .TP
103 .B EDOM
104 The denominator
105 .I y
106 is zero.
107 .SH "CONFORMING TO"
108 IEC 60559.
109 The functions
110 .BR remainder (),
111 .BR remainderf (),
112 and
113 .BR remainderl ()
114 are from C99.
115 The function
116 .BR drem ()
117 is from 4.3BSD.
118 The
119 .I float
120 and
121 .I "long double"
122 variants
123 .BR dremf ()
124 and
125 .BR dreml ()
126 exist on some systems, such as Tru64 and glibc2.
127 .SH EXAMPLE
128 The call "remainder(29.0, 3.0)" returns \-1.
129 .SH "SEE ALSO"
130 .BR fmod (3),
131 .BR remquo (3)