1FDIM(3P)                   POSIX Programmer's Manual                  FDIM(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       fdim, fdimf, fdiml — compute positive difference between two  floating-
13       point numbers
14

SYNOPSIS

16       #include <math.h>
17
18       double fdim(double x, double y);
19       float fdimf(float x, float y);
20       long double fdiml(long double x, long double y);
21

DESCRIPTION

23       The  functionality described on this reference page is aligned with the
24       ISO C standard. Any conflict between the  requirements  described  here
25       and  the  ISO C  standard is unintentional. This volume of POSIX.1‐2017
26       defers to the ISO C standard.
27
28       These functions shall determine the positive difference  between  their
29       arguments.  If  x is greater than y, x-y is returned. If x is less than
30       or equal to y, +0 is returned.
31
32       An application wishing to check for error situations should  set  errno
33       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
34       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
35       FE_DIVBYZERO  |  FE_OVERFLOW  | FE_UNDERFLOW) is non-zero, an error has
36       occurred.
37

RETURN VALUE

39       Upon successful completion, these functions shall return  the  positive
40       difference value.
41
42       If x-y is positive and overflows, a range error shall occur and fdim(),
43       fdimf(), and fdiml() shall return the  value  of  the  macro  HUGE_VAL,
44       HUGE_VALF, and HUGE_VALL, respectively.
45
46       If  the  correct  value would cause underflow, a range error may occur,
47       and fdim(), fdimf(), and fdiml() shall return the correct value, or (if
48       the  IEC  60559  Floating-Point option is not supported) an implementa‐
49       tion-defined value no greater in magnitude than DBL_MIN,  FLT_MIN,  and
50       LDBL_MIN, respectively.
51
52       If x or y is NaN, a NaN shall be returned.
53

ERRORS

55       The fdim() function shall fail if:
56
57       Range Error The result overflows.
58
59                   If  the  integer expression (math_errhandling & MATH_ERRNO)
60                   is non-zero, then errno shall be set to [ERANGE].   If  the
61                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
62                   non-zero, then the overflow floating-point exception  shall
63                   be raised.
64
65       The fdim() function may fail if:
66
67       Range Error The result underflows.
68
69                   If  the  integer expression (math_errhandling & MATH_ERRNO)
70                   is non-zero, then errno shall be set to [ERANGE].   If  the
71                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
72                   non-zero, then the underflow floating-point exception shall
73                   be raised.
74
75       The following sections are informative.
76

EXAMPLES

78       None.
79

APPLICATION USAGE

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

RATIONALE

86       None.
87

FUTURE DIRECTIONS

89       None.
90

SEE ALSO

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