1FDIM(P) POSIX Programmer's Manual FDIM(P)
2
3
4
6 fdim, fdimf, fdiml - compute positive difference between two floating-
7 point numbers
8
10 #include <math.h>
11
12 double fdim(double x, double y);
13 float fdimf(float x, float y);
14 long double fdiml(long double x, long double y);
15
16
18 These functions shall determine the positive difference between their
19 arguments. If x is greater than y, x- y is returned. If x is less than
20 or equal to y, +0 is returned.
21
22 An application wishing to check for error situations should set errno
23 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
24 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID
25 | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
26 occurred.
27
29 Upon successful completion, these functions shall return the positive
30 difference value.
31
32 If x- y is positive and overflows, a range error shall occur and
33 fdim(), fdimf(), and fdiml() shall return the value of the macro
34 HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively.
35
36 If x- y is positive and underflows, a range error may occur, and either
37 ( x- y) (if representable), or 0.0 (if supported), or an implementa‐
38 tion-defined value shall be returned.
39
40 If x or y is NaN, a NaN shall be returned.
41
43 The fdim() function shall fail if:
44
45 Range Error
46 The result overflows.
47
48 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
49 then errno shall be set to [ERANGE]. If the integer expression
50 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow
51 floating-point exception shall be raised.
52
53
54 The fdim() function may fail if:
55
56 Range Error
57 The result underflows.
58
59 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
60 then errno shall be set to [ERANGE]. If the integer expression
61 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
62 floating-point exception shall be raised.
63
64
65 The following sections are informative.
66
68 None.
69
71 On implementations supporting IEEE Std 754-1985, x- y cannot underflow,
72 and hence the 0.0 return value is shaded as an extension for implemen‐
73 tations supporting the XSI extension rather than an MX extension.
74
75 On error, the expressions (math_errhandling & MATH_ERRNO) and
76 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
77 at least one of them must be non-zero.
78
80 None.
81
83 None.
84
86 feclearexcept() , fetestexcept() , fmax() , fmin() , the Base Defini‐
87 tions volume of IEEE Std 1003.1-2001, Section 4.18, Treatment of Error
88 Conditions for Mathematical Functions, <math.h>
89
91 Portions of this text are reprinted and reproduced in electronic form
92 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
93 -- Portable Operating System Interface (POSIX), The Open Group Base
94 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
95 Electrical and Electronics Engineers, Inc and The Open Group. In the
96 event of any discrepancy between this version and the original IEEE and
97 The Open Group Standard, the original IEEE and The Open Group Standard
98 is the referee document. The original Standard can be obtained online
99 at http://www.opengroup.org/unix/online.html .
100
101
102
103IEEE/The Open Group 2003 FDIM(P)