Name

fmax, fmaxf, fmaxl, fmin, fminf, fminl
- find maximum value

Library

libm.lib

Synopsis

  #include <math.h>
  double fmax (double x, double y);
  float fmaxf (float x, float y);
  long double fmaxl (long double x, long double y);
  double fmin (double x, double y);
  float fminf (float x, float y);
  long double fminl (long double x, long double y);

Detailed description

The fmax, fmaxf, and fmaxl functions return the larger of x and y, and likewise, the fmin, fminf, and fminl functions return the smaller of x and y. They treat +0.0 as being larger than -0.0. If one argument is an NaN(Not a Number), then the other argument is returned. If both arguments are NaN(Not a Number)s, then the result is an NaN(Not a Number).

Examples

#include <math.h>
int main( void )
{
   double y;
   y = fmax( 0, -9 );
   printf( "fmax ( 0, -9) = %f\n", y );
   y = fmaxf( 0, -9 );
   printf( "fmaxf( 0, -9) = %f\n", y );
   y = fmaxl( 0, -9 );
   printf( "fmaxl( 0, -9) = %f\n", y );
   y = fmin( 0, -9 );
   printf( "fmin ( 0, -9) = %f\n", y );
   y = fminf( 0, -9 );
   printf( "fminf ( 0, -9) = %f\n", y );
   y = fminl( 0, -9 );
   printf( "fminl ( 0, -9) = %f\n", y );
}

         

Output

fmax( 0, -9 ) = 0
fmaxf( 0, -9 ) = 0
fmaxl( 0, -9 ) = 0
fmin( 0, -9 ) = -9
fminf( 0, -9 ) = -9
fminl( 0, -9 ) = -9

         


See also

fabs, fdim, math

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top