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(): _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
27       _ISOC99_SOURCE; or cc -std=c99
28       remainderf(), remainderl(): _SVID_SOURCE || _BSD_SOURCE ||
29       _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; or cc -std=c99
30       drem(), dremf(), dreml(): _SVID_SOURCE || _BSD_SOURCE
31

DESCRIPTION

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

RETURN VALUE

44       On success, these functions return the floating-point remainder, x-n*y.
45       If the return value is 0, it has the sign of x.
46
47       If x or y is a NaN, a NaN is returned.
48
49       If  x  is an infinity, and y is not a NaN, a domain error occurs, and a
50       NaN is returned.
51
52       If y is zero, and x is not a NaN, a domain error occurs, and a  NaN  is
53       returned.
54

ERRORS

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

CONFORMING TO

71       The functions remainder(), remainderf(), and remainderl() are specified
72       in C99 and POSIX.1-2001.
73
74       The function drem() is from 4.3BSD.  The float and long double variants
75       dremf()  and  dreml()  exist on some systems, such as Tru64 and glibc2.
76       Avoid the use of these functions in favor of remainder() etc.
77

BUGS

79       The call
80
81           remainder(nan(""), 0);
82
83       returns a NaN, as expected, but  wrongly  causes  a  domain  error;  it
84       should yield a silent NaN.
85

EXAMPLE

87       The call "remainder(29.0, 3.0)" returns -1.
88

SEE ALSO

90       div(3), fmod(3), remquo(3)
91

COLOPHON

93       This  page  is  part of release 3.25 of the Linux man-pages project.  A
94       description of the project, and information about reporting  bugs,  can
95       be found at http://www.kernel.org/doc/man-pages/.
96
97
98
99                                  2009-02-04                      REMAINDER(3)
Impressum