1FMOD(P)                    POSIX Programmer's Manual                   FMOD(P)
2
3
4

NAME

6       fmod, fmodf, fmodl - floating-point remainder value function
7

SYNOPSIS

9       #include <math.h>
10
11       double fmod(double x, double y);
12       float fmodf(float x, float y);
13       long double fmodl(long double x, long double y);
14
15

DESCRIPTION

17       These  functions shall return the floating-point remainder of the divi‐
18       sion of x by y.
19
20       An application wishing to check for error situations should  set  errno
21       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
22       functions.  On return, if errno is non-zero or  fetestexcept(FE_INVALID
23       |  FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
24       occurred.
25

RETURN VALUE

27       These functions shall return the value x- i* y, for some integer i such
28       that, if y is non-zero, the result has the same sign as x and magnitude
29       less than the magnitude of y.
30
31       If the correct value would cause underflow, and is not representable, a
32       range error may occur, and    either 0.0 (if supported), or   an imple‐
33       mentation-defined value shall be returned.
34
35       If x or y is NaN, a NaN shall be returned.
36
37       If y is zero, a domain error shall occur, and either  a  NaN  (if  sup‐
38       ported), or an implementation-defined value shall be returned.
39
40       If x is infinite, a domain error shall occur, and either a NaN (if sup‐
41       ported), or an implementation-defined value shall be returned.
42
43       If x is ±0 and y is not zero, ±0 shall be returned.
44
45       If x is not infinite and y is ±Inf, x shall be returned.
46
47       If the correct value would cause underflow,  and  is  representable,  a
48       range error may occur and the correct value shall be returned.
49

ERRORS

51       These functions shall fail if:
52
53       Domain Error
54              The x argument is infinite or y is zero.
55
56       If  the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
57       then  errno  shall  be  set  to  [EDOM].  If  the  integer   expression
58       (math_errhandling  &  MATH_ERREXCEPT)  is  non-zero,  then  the invalid
59       floating-point exception shall be raised.
60
61
62       These functions may fail if:
63
64       Range Error
65              The result underflows.
66
67       If the integer expression (math_errhandling & MATH_ERRNO) is  non-zero,
68       then  errno  shall  be  set  to  [ERANGE].  If  the  integer expression
69       (math_errhandling & MATH_ERREXCEPT) is  non-zero,  then  the  underflow
70       floating-point exception shall be raised.
71
72
73       The following sections are informative.
74

EXAMPLES

76       None.
77

APPLICATION USAGE

79       On   error,   the   expressions  (math_errhandling  &  MATH_ERRNO)  and
80       (math_errhandling & MATH_ERREXCEPT) are independent of each other,  but
81       at least one of them must be non-zero.
82

RATIONALE

84       None.
85

FUTURE DIRECTIONS

87       None.
88

SEE ALSO

90       feclearexcept()  , fetestexcept() , isnan() , the Base Definitions vol‐
91       ume of IEEE Std 1003.1-2001, Section 4.18, Treatment  of  Error  Condi‐
92       tions for Mathematical Functions, <math.h>
93
95       Portions  of  this text are reprinted and reproduced in electronic form
96       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
97       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
98       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
99       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
100       event of any discrepancy between this version and the original IEEE and
101       The  Open Group Standard, the original IEEE and The Open Group Standard
102       is the referee document. The original Standard can be  obtained  online
103       at http://www.opengroup.org/unix/online.html .
104
105
106
107IEEE/The Open Group                  2003                              FMOD(P)
Impressum