1FMOD(3P) POSIX Programmer's Manual FMOD(3P)
2
3
4
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
12 fmod, fmodf, fmodl - floating-point remainder value function
13
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
21
23 These functions shall return the floating-point remainder of the divi‐
24 sion of x by y.
25
26 An application wishing to check for error situations should set errno
27 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
28 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID
29 | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
30 occurred.
31
33 These functions shall return the value x- i* y, for some integer i such
34 that, if y is non-zero, the result has the same sign as x and magnitude
35 less than the magnitude of y.
36
37 If the correct value would cause underflow, and is not representable, a
38 range error may occur, and either 0.0 (if supported), or an implemen‐
39 tation-defined value shall be returned.
40
41 If x or y is NaN, a NaN shall be returned.
42
43 If y is zero, a domain error shall occur, and either a NaN (if sup‐
44 ported), or an implementation-defined value shall be returned.
45
46 If x is infinite, a domain error shall occur, and either a NaN (if sup‐
47 ported), or an implementation-defined value shall be returned.
48
49 If x is ±0 and y is not zero, ±0 shall be returned.
50
51 If x is not infinite and y is ±Inf, x shall be returned.
52
53 If the correct value would cause underflow, and is representable, a
54 range error may occur and the correct value shall be returned.
55
57 These functions shall fail if:
58
59 Domain Error
60 The x argument is infinite or y is zero.
61
62 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
63 then errno shall be set to [EDOM]. If the integer expression
64 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid
65 floating-point exception shall be raised.
66
67
68 These functions may fail if:
69
70 Range Error
71 The result underflows.
72
73 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
74 then errno shall be set to [ERANGE]. If the integer expression
75 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
76 floating-point exception shall be raised.
77
78
79 The following sections are informative.
80
82 None.
83
85 On error, the expressions (math_errhandling & MATH_ERRNO) and
86 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
87 at least one of them must be non-zero.
88
90 None.
91
93 None.
94
96 feclearexcept(), fetestexcept(), isnan(), the Base Definitions volume
97 of IEEE Std 1003.1-2001, Section 4.18, Treatment of Error Conditions
98 for Mathematical Functions, <math.h>
99
101 Portions of this text are reprinted and reproduced in electronic form
102 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
103 -- Portable Operating System Interface (POSIX), The Open Group Base
104 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
105 Electrical and Electronics Engineers, Inc and The Open Group. In the
106 event of any discrepancy between this version and the original IEEE and
107 The Open Group Standard, the original IEEE and The Open Group Standard
108 is the referee document. The original Standard can be obtained online
109 at http://www.opengroup.org/unix/online.html .
110
111
112
113IEEE/The Open Group 2003 FMOD(3P)