Name

fmax

Synopsis

Determines the greater of two floating-point numbers

#include <math.h>
doublefmax( double x, double y );
float fmaxf( float x, float y );
long double fmaxl( long double x , long double y );

The fmax() functions return the value of the greater argument.

Example:

// Let big equal the second-greatest possible double value ...
const double big = nextafter( DBL_MAX, 0.0 );
// ... and small the second-least possible double value:
const double small = nextafter( DBL_MIN, 0.0 );

double a, b, c;

/* ... */

if ( fmin( fmin( a, b ), c ) <= small )
  printf( "At least one value is too small.\n" );
if (fmax( fmax( a, b ), c ) >= big )
  printf( "At least one value is too great.\n" );

See Also

fabs(), fmin()

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.