1fdim(3) Library Functions Manual fdim(3)
2
3
4
6 fdim, fdimf, fdiml - positive difference
7
9 Math library (libm, -lm)
10
12 #include <math.h>
13
14 double fdim(double x, double y);
15 float fdimf(float x, float y);
16 long double fdiml(long double x, long double y);
17
18 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20 fdimf(), fdiml():
21 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
22
24 These functions return the positive difference, max(x-y,0), between
25 their arguments.
26
28 On success, these functions return the positive difference.
29
30 If x or y is a NaN, a NaN is returned.
31
32 If the result overflows, a range error occurs, and the functions return
33 HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively.
34
36 See math_error(7) for information on how to determine whether an error
37 has occurred when calling these functions.
38
39 The following errors can occur:
40
41 Range error: result overflow
42 errno is set to ERANGE. An overflow floating-point exception
43 (FE_OVERFLOW) is raised.
44
46 For an explanation of the terms used in this section, see at‐
47 tributes(7).
48
49 ┌────────────────────────────────────────────┬───────────────┬─────────┐
50 │Interface │ Attribute │ Value │
51 ├────────────────────────────────────────────┼───────────────┼─────────┤
52 │fdim(), fdimf(), fdiml() │ Thread safety │ MT-Safe │
53 └────────────────────────────────────────────┴───────────────┴─────────┘
54
56 C11, POSIX.1-2008.
57
59 glibc 2.1. C99, POSIX.1-2001.
60
62 Before glibc 2.24 on certain architectures (e.g., x86, but not x86_64)
63 these functions did not set errno.
64
66 fmax(3)
67
68
69
70Linux man-pages 6.04 2023-03-30 fdim(3)