1MAX(3)                     Library Functions Manual                     MAX(3)
2
3
4

NAME

6       MAX, MIN - maximum or minimum of two values
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <sys/param.h>
13
14       MAX(a, b);
15       MIN(a, b);
16

DESCRIPTION

18       These macros return the maximum or minimum of a and b.
19

RETURN VALUE

21       These  macros return the value of one of their arguments, possibly con‐
22       verted to a different type (see BUGS).
23

ERRORS

25       These macros may raise the "invalid" floating-point exception when  any
26       of the arguments is NaN.
27

STANDARDS

29       GNU, BSD.
30

NOTES

32       If  either of the arguments is of a floating-point type, you might pre‐
33       fer to use fmax(3) or fmin(3), which can handle NaN.
34
35       The arguments may be evaluated more than once, or not at all.
36
37       Some UNIX systems might provide these macros in a different header,  or
38       not at all.
39

BUGS

41       Due to the usual arithmetic conversions, the result of these macros may
42       be very different from either of the arguments.  To avoid this,  ensure
43       that both arguments have the same type.
44

EXAMPLES

46       #include <stdio.h>
47       #include <stdlib.h>
48       #include <sys/param.h>
49
50       int
51       main(int argc, char *argv[])
52       {
53           int a, b, x;
54
55           if (argc != 3) {
56               fprintf(stderr, "Usage: %s <num> <num>\n", argv[0]);
57               exit(EXIT_FAILURE);
58           }
59
60           a = atoi(argv[1]);
61           b = atoi(argv[2]);
62           x = MAX(a, b);
63           printf("MAX(%d, %d) is %d\n", a, b, x);
64
65           exit(EXIT_SUCCESS);
66       }
67

SEE ALSO

69       fmax(3), fmin(3)
70
71
72
73Linux man-pages 6.04              2023-03-30                            MAX(3)
Impressum