다음을 통해 공유


fdim, fdimf, fdiml

 

The latest version of this topic can be found at fdim, fdimf, fdiml.

Determines the positive difference between the first and second values.

Syntax

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.

Return 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.

Remarks

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).

Requirements

Function C header C++ header
fdim, fdimf, fdiml <math.h> <cmath>

For additional compatibility information, see Compatibility.

See Also

Alphabetical Function Reference
fmax, fmaxf, fmaxl
abs, labs, llabs, _abs64