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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       fmod, fmodf, fmodl — floating-point remainder value function
13

SYNOPSIS

15       #include <math.h>
16
17       double fmod(double x, double y);
18       float fmodf(float x, float y);
19       long double fmodl(long double x, long double y);
20

DESCRIPTION

22       The functionality described on this reference page is aligned with  the
23       ISO C  standard.  Any  conflict between the requirements described here
24       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
25       defers to the ISO C standard.
26
27       These  functions shall return the floating-point remainder of the divi‐
28       sion of x by y.
29
30       An application wishing to check for error situations should  set  errno
31       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
32       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
33       FE_DIVBYZERO  |  FE_OVERFLOW  | FE_UNDERFLOW) is non-zero, an error has
34       occurred.
35

RETURN VALUE

37       These functions shall return the value x-i*y, for some integer  i  such
38       that, if y is non-zero, the result has the same sign as x and magnitude
39       less than the magnitude of y.
40
41       If the correct value would cause underflow, and is not representable, a
42       range  error  may  occur,  and fmod(), modf(), and fmodl() shall return
43       0.0, or (if the IEC 60559 Floating-Point option is  not  supported)  an
44       implementation-defined  value  no  greater  in  magnitude than DBL_MIN,
45       FLT_MIN, and LDBL_MIN, respectively.
46
47       If x or y is NaN, a NaN shall be returned, and none of  the  conditions
48       below shall be considered.
49
50       If y is zero, a domain error shall occur, and a NaN shall be returned.
51
52       If  x  is  infinite,  a  domain  error  shall occur, and a NaN shall be
53       returned.
54
55       If x is ±0 and y is not zero, ±0 shall be returned.
56
57       If x is not infinite and y is ±Inf, x shall be returned.
58
59       If the correct value would cause underflow,  and  is  representable,  a
60       range error may occur and the correct value shall be returned.
61

ERRORS

63       These functions shall fail if:
64
65       Domain Error
66                   The x argument is infinite or y is zero.
67
68                   If  the  integer expression (math_errhandling & MATH_ERRNO)
69                   is non-zero, then errno shall be set  to  [EDOM].   If  the
70                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
71                   non-zero, then the invalid floating-point  exception  shall
72                   be raised.
73
74       These functions may fail if:
75
76       Range Error The result underflows.
77
78                   If  the  integer expression (math_errhandling & MATH_ERRNO)
79                   is non-zero, then errno shall be set to [ERANGE].   If  the
80                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
81                   non-zero, then the underflow floating-point exception shall
82                   be raised.
83
84       The following sections are informative.
85

EXAMPLES

87       None.
88

APPLICATION USAGE

90       On   error,   the   expressions  (math_errhandling  &  MATH_ERRNO)  and
91       (math_errhandling & MATH_ERREXCEPT) are independent of each other,  but
92       at least one of them must be non-zero.
93

RATIONALE

95       None.
96

FUTURE DIRECTIONS

98       None.
99

SEE ALSO

101       feclearexcept(), fetestexcept(), isnan()
102
103       Section 4.20, Treatment of Error Conditions for Mathematical Functions,
104       <math.h>
105
107       Portions of this text are reprinted and reproduced in  electronic  form
108       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
109       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
110       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
111       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
112       event of any discrepancy between this version and the original IEEE and
113       The Open Group Standard, the original IEEE and The Open Group  Standard
114       is  the  referee document. The original Standard can be obtained online
115       at http://www.opengroup.org/unix/online.html .
116
117       Any typographical or formatting errors that appear  in  this  page  are
118       most likely to have been introduced during the conversion of the source
119       files to man page format. To report such errors,  see  https://www.ker
120       nel.org/doc/man-pages/reporting_bugs.html .
121
122
123
124IEEE/The Open Group                  2017                             FMOD(3P)
Impressum