1remainder(3)               Library Functions Manual               remainder(3)
2
3
4

NAME

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

LIBRARY

10       Math library (libm, -lm)
11

SYNOPSIS

13       #include <math.h>
14
15       double remainder(double x, double y);
16       float remainderf(float x, float y);
17       long double remainderl(long double x, long double y);
18
19       /* Obsolete synonyms */
20       [[deprecated]] double drem(double x, double y);
21       [[deprecated]] float dremf(float x, float y);
22       [[deprecated]] long double dreml(long double x, long double y);
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

STANDARDS

91       remainder()
92       remainderf()
93       remainderl()
94              C11, POSIX.1-2008.
95
96       drem()
97       dremf()
98       dreml()
99              None.
100

HISTORY

102       remainder()
103       remainderf()
104       remainderl()
105              C99, POSIX.1-2001.
106
107       drem() 4.3BSD.
108
109       dremf()
110       dreml()
111              Tru64, glibc2.
112

BUGS

114       Before glibc 2.15, the call
115
116           remainder(nan(""), 0);
117
118       returned  a NaN, as expected, but wrongly caused a domain error.  Since
119       glibc 2.15, a silent NaN (i.e., no domain error) is returned.
120
121       Before glibc 2.15, errno was not set to EDOM for the domain error  that
122       occurs when x is an infinity and y is not a NaN.
123

EXAMPLES

125       The call "remainder(29.0, 3.0)" returns -1.
126

SEE ALSO

128       div(3), fmod(3), remquo(3)
129
130
131
132Linux man-pages 6.04              2023-03-30                      remainder(3)
Impressum