fmax - C math.h

C examples for math.h:fmax

Type

function

From

<cmath>
<ctgmath>
<math.h>

Description

Returns the larger of its arguments: either x or y. If one of the arguments in a NaN, the other is returned.

Prototype

long double fmaxl (long double x, long double y);
long double fmax (long double x, long double y);
     double fmax  (double x, double y);
      float fmaxf (float x , float y);
      float fmax (float x  , float y);
     double fmax (Type1 x  , Type2 y);       

Parameters

Parameter Description
x, y Values among which the function selects a maximum.

Return Value

The maximum numeric value of its arguments.

Example

Demo Code


#include <stdio.h>
#include <math.h> /* fmax */

int main ()// w  w  w  . j av a2s.co m
{
  printf ("%f\n", fmax(100.0,1.0));
  
  printf ("%f\n", fmax(-100.0,1.0));
  
  printf ("%f\n", fmax(-1.0,1.0));
  
  printf ("%f\n", fmax(-1.0,-1.0));
  
  printf ("%f\n", fmax(-100.0,-1.0));
  return 0;
}

Related Tutorials