fdim, fdimf, fdiml
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at fdim, fdimf, fdiml.
Determines the positive difference between the first and second values.
double fdim( double x, double y ); float fdim( float x, float y ); //C++ only long double fdim( long double x, long double y ); //C++ only float fdimf( float x, float y ); long double fdiml( long double x, long double y );
Parameters
[in] x
The first value.
[in] y
The second value.
Returns the positive difference between x and y:
| Return value | Scenario |
|---|---|
| x-y | if x > y |
| 0 | if x <= y |
Otherwise, may return one of the following errors:
| Issue | Return |
|---|---|
| Overflow range error | +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL |
| Underflow range error | correct value (after rounding) |
x or y is NaN | NaN |
Errors are reported as specified in _matherr.
Because C++ allows overloading, you can call overloads of fdim that take and return float and long double types. In a C program, fdim always takes and returns a double.
Except for the NaN handling, this function is equivalent to fmax, fmaxf, fmaxl(x-y, 0).
| Function | C header | C++ header |
|---|---|---|
fdim, fdimf, fdiml | <math.h> | <cmath> |
For additional compatibility information, see Compatibility.
Alphabetical Function Reference
fmax, fmaxf, fmaxl
abs, labs, llabs, _abs64