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           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
28               || _XOPEN_SOURCE >= 500
29               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
30               || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
31       remainderf(), remainderl():
32           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
33               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
34               || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
35       drem(), dremf(), dreml():
36           /* Since glibc 2.19: */ _DEFAULT_SOURCE
37               || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
38

DESCRIPTION

40       These functions compute the remainder of dividing x by y.   The  return
41       value  is x-n*y, where n is the value x / y, rounded to the nearest in‐
42       teger.  If the absolute value of x-n*y is 0.5, n is chosen to 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              errno  is set to EDOM (but see BUGS).  An invalid floating-point
69              exception (FE_INVALID) is raised.
70
71              These functions do not set errno for this case.
72
73       Domain error: y is zero
74              errno is set  to  EDOM.   An  invalid  floating-point  exception
75              (FE_INVALID) is raised.
76

ATTRIBUTES

78       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
79       tributes(7).
80
81       ┌───────────────────────────┬───────────────┬─────────┐
82Interface                  Attribute     Value   
83       ├───────────────────────────┼───────────────┼─────────┤
84drem(), dremf(), dreml(),  │ Thread safety │ MT-Safe │
85remainder(), remainderf(), │               │         │
86remainderl()               │               │         │
87       └───────────────────────────┴───────────────┴─────────┘

CONFORMING TO

89       The functions remainder(), remainderf(), and remainderl() are specified
90       in C99, POSIX.1-2001, and POSIX.1-2008.
91
92       The function drem() is from 4.3BSD.  The float and long double variants
93       dremf() and dreml() exist on some systems, such as  Tru64  and  glibc2.
94       Avoid the use of these functions in favor of remainder() etc.
95

BUGS

97       Before glibc 2.15, the call
98
99           remainder(nan(""), 0);
100
101       returned  a NaN, as expected, but wrongly caused a domain error.  Since
102       glibc 2.15, a silent NaN (i.e., no domain error) is returned.
103
104       Before glibc 2.15, errno was not set to EDOM for the domain error  that
105       occurs when x is an infinity and y is not a NaN.
106

EXAMPLES

108       The call "remainder(29.0, 3.0)" returns -1.
109

SEE ALSO

111       div(3), fmod(3), remquo(3)
112

COLOPHON

114       This  page  is  part of release 5.10 of the Linux man-pages project.  A
115       description of the project, information about reporting bugs,  and  the
116       latest     version     of     this    page,    can    be    found    at
117       https://www.kernel.org/doc/man-pages/.
118
119
120
121                                  2020-06-09                      REMAINDER(3)
Impressum