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
42       integer.  If the absolute value of x-n*y is 0.5,  n  is  chosen  to  be
43       even.
44
45       These  functions  are  unaffected  by  the  current  rounding mode (see
46       fenv(3)).
47
48       The drem() function does precisely the same thing.
49

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

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

CONFORMING TO

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

BUGS

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

EXAMPLE

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

SEE ALSO

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

COLOPHON

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