In C, fmin() returns the smaller of two double values. fmin(3.5, 1.2) is 1.2. It is the usual floating-point “min” from <math.h> (C99 and later).
If one argument is NaN and the other is a number, fmin() typically returns the number. Both arguments are required. For an int minimum you would write your own compare — fmin is for floating types.
Syntax
Pass two floating-point numbers. Start with this call.
C
fmin(3.5, 1.2);
Call
What it does
fmin(3.5, 1.2)
Returns 1.2, the smaller value.
Include <math.h>. On GCC, link with -lm. Pair it with fmax() for the larger value. Newer C23 names like fminimum() differ mainly in NaN rules.
Library declarations
C
double fmin(double x, double y);
float fminf(float x, float y);
long double fminl(long double x, long double y);
Parameters
Parameter
Description
x
Required. First double.
y
Required. Second double.
Return Value
Return Value
Description
double
The smaller of the two values. If one is NaN, the other number is preferred.