1REMAINDER(3)               Linux Programmer's Manual              REMAINDER(3)
2
3
4

NAME

6       drem,  dremf, dreml, remainder, remainderf, remainderl - floating-point
7       remainder function
8

SYNOPSIS

10       #include <math.h>
11
12       /* The C99 versions */
13       double remainder(double x, double y);
14       float remainderf(float x, float y);
15       long double remainderl(long double x, long double y);
16
17       /* Obsolete synonyms */
18       double drem(double x, double y);
19       float dremf(float x, float y);
20       long double dreml(long double x, long double y);
21
22       Link with -lm.
23
24   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
25
26       remainder():
27           _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
28           _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _ISOC99_SOURCE ||
29           _POSIX_C_SOURCE >= 200112L;
30           or cc -std=c99
31       remainderf(), remainderl():
32           _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 ||
33           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
34           or cc -std=c99
35       drem(), dremf(), dreml():
36           _SVID_SOURCE || _BSD_SOURCE
37

DESCRIPTION

39       The  remainder()  function  computes  the remainder of dividing x by y.
40       The return value is x-n*y, where n is the value x / y, rounded  to  the
41       nearest integer.  If the absolute value of x-n*y is 0.5, n is chosen to
42       be even.
43
44       These functions are  unaffected  by  the  current  rounding  mode  (see
45       fenv(3)).
46
47       The drem() function does precisely the same thing.
48

RETURN VALUE

50       On success, these functions return the floating-point remainder, x-n*y.
51       If the return value is 0, it has the sign of x.
52
53       If x or y is a NaN, a NaN is returned.
54
55       If x is an infinity, and y is not a NaN, a domain error occurs,  and  a
56       NaN is returned.
57
58       If  y  is zero, and x is not a NaN, a domain error occurs, and a NaN is
59       returned.
60

ERRORS

62       See math_error(7) for information on how to determine whether an  error
63       has occurred when calling these functions.
64
65       The following errors can occur:
66
67       Domain error: x is an infinity and y is not a NaN
68              An invalid floating-point exception (FE_INVALID) is raised.
69
70              These functions do not set errno for this case.
71
72       Domain error: y is zero
73              errno  is  set  to  EDOM.   An  invalid floating-point exception
74              (FE_INVALID) is raised.
75

CONFORMING TO

77       The functions remainder(), remainderf(), and remainderl() are specified
78       in C99 and POSIX.1-2001.
79
80       The function drem() is from 4.3BSD.  The float and long double variants
81       dremf() and dreml() exist on some systems, such as  Tru64  and  glibc2.
82       Avoid the use of these functions in favor of remainder() etc.
83

BUGS

85       The call
86
87           remainder(nan(""), 0);
88
89       returns  a  NaN,  as  expected,  but  wrongly causes a domain error; it
90       should yield a silent NaN.
91

EXAMPLE

93       The call "remainder(29.0, 3.0)" returns -1.
94

SEE ALSO

96       div(3), fmod(3), remquo(3)
97

COLOPHON

99       This page is part of release 3.53 of the Linux  man-pages  project.   A
100       description  of  the project, and information about reporting bugs, can
101       be found at http://www.kernel.org/doc/man-pages/.
102
103
104
105                                  2010-09-20                      REMAINDER(3)
Impressum