Share via


__min

Returns the smaller of two values.

type**__min(typea,typeb);**

Routine Required Header Compatibility
__min <stdlib.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

The smaller of the two arguments

Parameters

type

Any numeric data type

a, b

Values of any numeric type to be compared

Remarks

The __min macro compares two values and returns the value of the smaller one. The arguments can be of any numeric data type, signed or unsigned. Both arguments and the return value must be of the same data type.

Example

/* MINMAX.C */

#include <stdlib.h>
#include <stdio.h>

void main( void )
{
   int a = 10;
   int b = 21;

   printf( "The larger of %d and %d is %d\n",  a, b, __max( a, b ) );
   printf( "The smaller of %d and %d is %d\n", a, b, __min( a, b ) );
}

Output

The larger of 10 and 21 is 21
The smaller of 10 and 21 is 10

Floating-Point Support Routines

See Also   __max