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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

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

CONFORMING TO

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

BUGS

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

EXAMPLES

110       The call "remainder(29.0, 3.0)" returns -1.
111

SEE ALSO

113       div(3), fmod(3), remquo(3)
114

COLOPHON

116       This page is part of release 5.13 of the Linux  man-pages  project.   A
117       description  of  the project, information about reporting bugs, and the
118       latest    version    of    this    page,    can     be     found     at
119       https://www.kernel.org/doc/man-pages/.
120
121
122
123                                  2021-03-22                      REMAINDER(3)
Impressum