Skip to content

Latest commit

 

History

History
95 lines (69 loc) · 2.52 KB

fdim-fdimf-fdiml.md

File metadata and controls

95 lines (69 loc) · 2.52 KB
title description ms.date api_name api_location api_type topic_type f1_keywords helpviewer_keywords
fdim, fdimf, fdiml
API reference for fdim, fdimf, and fdiml; which determines the positive difference between two values.
9/1/2020
fdim
fdimf
fdiml
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-math-l1-1-0.dll
DLLExport
apiref
fdim
fdimf
fdiml
math/fdim
math/fdimf
math/fdiml
fdim function
fdimf function
fdiml function

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

#define fdim(X) // Requires C11 or higher

Parameters

x
The first value.

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, unless you're using the <tgmath.h> macro to call this function, fdim always takes and returns a double.

If you use the <tgmath.h> fdim() macro, the type of the argument determines which version of the function is selected. See Type-generic math for details.

Except for the NaN handling, this function is equivalent to fmax(x - y, 0).

Requirements

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

For more compatibility information, see Compatibility.

See also

Alphabetical function reference
fmax, fmaxf, fmaxl
abs, labs, llabs, _abs64