fmin()
is a C library function that returns the smaller numeric value of its two arguments.
#include<math.h>
Following is the declaration of fmin()
where x
and y
are the floating-point values to be compared:
double fmin(double x, double y);
Note: An integer can also be passed as a parameter to
fmin()
, but will be implicitly cast todouble
datatype.
The function returns the smaller number of the two numbers as double
.
The code below runs the fmin()
function on different examples:
#include<stdio.h>#include<math.h>int main() {printf("fmin(3, 4) = %f\n", fmin(3, 4)); //find min of 3 and 4printf("fmin(9, 7.8) = %f\n", fmin(9, 7.8)); //find min of 9 and 7.8printf("fmin(20.3, 20.4) = %f\n", fmin(20.3, 20.4)); //find min of 20.3 and 20.4printf("fmin(500.5, 500.5) = %f\n", fmin(500.5, 500.5)); //find min of 500.5 and 500.5printf("fmin(1.2, nan) = %f\n", fmin(1.2, NAN)); //find min of 1.2 and nanprintf("fmin(nan, 1000.2) = %f\n", fmin(NAN, 1000.2)); //find min of nan and 1000.2printf("fmin(nan, nan) = %f\n", fmin(NAN, NAN)); //find min of nan and nanprintf("fmin(-inf, nan) = %f\n", fmin(-INFINITY, NAN)); //find min of -infinity and nanprintf("fmin(inf, nan) = %f\n", fmin(INFINITY, NAN)); //find min of infinity and nanreturn 0;}
Free Resources