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
11

NAME

13       fdim, fdimf, fdiml — compute positive difference between two  floating-
14       point numbers
15

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

79       None.
80

APPLICATION USAGE

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

RATIONALE

87       None.
88

FUTURE DIRECTIONS

90       None.
91

SEE ALSO

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