The fmaxl()
function in C compares two numbers and returns the larger number.
To use the fmaxl()
function, the program needs to include the header file math.h
as shown below:
#include <math.h>
The exact
long double
value is returned without being rounded.
The following code demonstrates how to use the fmaxl()
function:
#include <stdio.h>#include <math.h>int main(void){// Example 1long double x = 3.678;long double y = 9.345;// get larger valuelong double max = fmaxl(x,y);printf("The larger value is %Lf.\n",max);// Example 2max = fmaxl(x, NAN);printf("The larger value is %Lf.\n",max);// Example 3max = fmaxl(NAN, NAN);printf("The larger value is %Lf.\n",max);}
If the inputs to the fmaxl()
function are two long double
values, the function returns the larger value.
If one input to the fmaxl()
function is NAN
and the second input is a long double
value, the function returns the long double
value.
If both inputs are NAN
, then the function returns NAN
.
Free Resources