fmax, fmaxf, fmaxl

Header: <math.h>

1-3) Returns the larger of two floating-point arguments, treating NaNs as missing data (between a NaN and a numeric value, the numeric value is chosen).

# Declarations

float fmaxf( float x, float y );

(since C99)

double fmax( double x, double y );

(since C99)

long double fmaxl( long double x, long double y );

(since C99)

#define fmax( x, y )

(since C99)

# Parameters

# Return value

If successful, returns the larger of two floating-point values. The value returned is exact and does not depend on any rounding modes.

# Notes

This function is not required to be sensitive to the sign of zero, although some implementations additionally enforce that if one argument is +0 and the other is -0, then +0 is returned.

# Example

#include <math.h>
#include <stdio.h>
 
int main(void)
{
    printf("fmax(2,1)    = %f\n", fmax(2,1));
    printf("fmax(-Inf,0) = %f\n", fmax(-INFINITY,0));
    printf("fmax(NaN,-1) = %f\n", fmax(NAN,-1));
}

# See also