[Previous]
[Contents]
[Next]

min(), __min()

return the lesser of two numbers

Synopsis:

#include <stdlib.h>

// C
#define min(a,b)  (((a) < (b)) ? (a) : (b))

// C++
#define __min(a,b)  (((a) < (b)) ? (a) : (b))

Description:

The C min() and C++ __min() macros evaluate to be the lesser of two values.

Returns:

The smaller of the two values.

Examples:

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

void main()
  {
    int a;

    /*
     * The following line will set the variable "a"
     * to 1, since 10 is greater than 1.
     */
    a = min( 1, 10 );
    printf( "The value is: %d\n", a );
  }

produces the output:

1

Classification:

WATCOM

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

Caveats:

min() and __min() are macros.

See also:

max()


[Previous]
[Contents]
[Next]