Facebook Page Twitter Page LinkedIn Page
× C Tutorial C Resources

The C math fmax() function is used to return maximum number between the two arguments. If one of the arguments is NaN, then the other argument is returned.


double fmax(double x, double y);
float fmaxf(float x, float y);
long double fmaxl(long double x, long double y);


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

Return Value

Returns the numerically maximum value.


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

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

The output of the above code will be:


❮ C <math.h> Library