fmin - C math.h

C examples for math.h:fmin

Type

function

From

<cmath>
<ctgmath>
<math.h>

Description

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

Prototype

long double fminl (long double x, long double y);
long double fmin (long double x, long double y);
     double fmin  (double x, double y);
      float fminf (float x , float y);
      float fmin (float x  , float y);
     double fmin (Type1 x  , Type2 y);       

Parameters

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

Return Value

The minimum numeric value of its arguments.

Example

Demo Code


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

int main ()/*from   w  w w.ja va2 s .  co m*/
{
  printf ("%f\n", fmin(100.0,1.0));
  printf ("%f\n", fmin(-100.0,1.0));
  
  printf ("%f\n", fmin(-1.0,1.0));
  
  printf ("%f\n", fmin(-1.0,-1.0));
  
  printf ("%f\n", fmin(-100.0,-1.0));
  return 0;
}

Related Tutorials