Facebook Page Twitter Page LinkedIn Page
× C Standard Library


The C <math.h> fmin() function returns minimum number between the two arguments. If one of the arguments is NaN, then the other argument is returned.

Syntax

double fmin (double x, double y);
float fminf (float x, float y);
long double fminl (long double x, long double y);

Parameters

x Specify value to compare.
y Specify value to compare.

Return Value

Returns the numerically minimum value.

Example:

In the below example, fmin() function is used to find out the minimum value between the two arguments.

#include <stdio.h>
#include <math.h>
 
int main (){
  printf("%.1lf\n", fmin(50, 100));
  printf("%.1lf\n", fmin(5.5, 10.5));
  printf("%.1lf\n", fmin(-2, 2)); 
  printf("%.1lf\n", fmin(-3, -2));  
  return 0;
}

The output of the above code will be:

50.0
5.5
-2.0
-3.0

❮ C <math.h> Library

5