fmax()
is a C library function that returns the larger numeric value of its two arguments.
#include<math.h>
Following is the declaration of fmax()
where x and y are the floating-point values to be compared:
double fmax(double x, double y);
Note: Integer(s) can also be passed as a parameter(s) to
fmax()
, but will be implicitly cast todouble
.
The function returns the larger of the two numbers as double
datatype.
What will fmax(-55.32, -55.321)
return?
-55.32
-55.321
-55.320000
-55.321000
The below code runs the fmax()
function on different example cases:
#include<stdio.h>#include<math.h>int main() {printf("fmax(3, 4) = %f\n", fmax(3, 4)); //find max of 3 and 4printf("fmax(9, 7.8) = %f\n", fmax(9, 7.8)); //find max of 9 and 7.8printf("fmax(20.3, 20.4) = %f\n", fmax(20.3, 20.4)); //find max of 20.3 and 20.4printf("fmax(500.5, 500.5) = %f\n", fmax(500.5, 500.5)); //find max of 500.5 and 500.5printf("fmax(1.2, nan) = %f\n", fmax(1.2, NAN)); //find max of 1.2 and nanprintf("fmax(nan, 1000.2) = %f\n", fmax(NAN, 1000.2)); //find max of nan and 1000.2printf("fmax(nan, nan) = %f\n", fmax(NAN, NAN)); //find max of nan and nanprintf("fmax(-inf, nan) = %f\n", fmax(-INFINITY, NAN)); //find max of -inf and nanprintf("fmax(inf, nan) = %f\n", fmax(INFINITY, NAN)); //find max of inf and nanreturn 0;}