[Previous] [Contents] [Next]

<limits.h>


Include the standard header <limits.h> to determine various properties of the integer type representations. The standard header <limits.h> is available even in a freestanding implementation.

You can test the values of all these macros in an if directive. (The macros are #if expressions.)

#define CHAR_BIT <#if expression >= 8>
#define CHAR_MAX <#if expression >= 127>
#define CHAR_MIN <#if expression <= 0>
#define SCHAR_MAX <#if expression >= 127>
#define SCHAR_MIN <#if expression <= -127>
#define UCHAR_MAX <#if expression >= 255>
#define MB_LEN_MAX <#if expression >= 1>

#define SHRT_MAX <#if expression >= 32,767>
#define SHRT_MIN <#if expression <= -32,767>
#define USHRT_MAX <#if expression >= 65,535>

#define INT_MAX <#if expression >= 32,767>
#define INT_MIN <#if expression <= -32,767>
#define UINT_MAX <#if expression >= 65,535>

#define LONG_MAX <#if expression >= 2,147,483,647>
#define LONG_MIN <#if expression <= -2,147,483,647>
#define ULONG_MAX <#if expression >= 4,294,967,295>

CHAR_BIT

#define CHAR_BIT <#if expression >= 8>

The macro yields the maximum value for the number of bits used to represent an object of type char.

CHAR_MAX

#define CHAR_MAX <#if expression >= 127>

The macro yields the maximum value for type char. Its value is:

CHAR_MIN

#define CHAR_MIN <#if expression <= 0>

The macro yields the minimum value for type char. Its value is:

INT_MAX

#define INT_MAX <#if expression >= 32,767>

The macro yields the maximum value for type int.

INT_MIN

#define INT_MIN <#if expression <= -32,767>

The macro yields the minimum value for type int.

LONG_MAX

#define LONG_MAX <#if expression >= 2,147,483,647>

The macro yields the maximum value for type long.

LONG_MIN

#define LONG_MIN <#if expression <= -2,147,483,647>

The macro yields the minimum value for type long.

MB_LEN_MAX

#define MB_LEN_MAX <#if expression >= 1>

The macro yields the maximum number of characters that constitute a multibyte character in any supported locale. Its value is >= MB_CUR_MAX.

SCHAR_MAX

#define SCHAR_MAX <#if expression >= 127>

The macro yields the maximum value for type signed char.

SCHAR_MIN

#define SCHAR_MIN <#if expression <= -127>

The macro yields the minimum value for type signed char.

SHRT_MAX

#define SHRT_MAX <#if expression >= 32,767>

The macro yields the maximum value for type short.

SHRT_MIN

#define SHRT_MIN <#if expression <= -32,767>

The macro yields the minimum value for type short.

UCHAR_MAX

#define UCHAR_MAX <#if expression >= 255>

The macro yields the maximum value for type unsigned char.

UINT_MAX

#define UINT_MAX <#if expression >= 65,535>

The macro yields the maximum value for type unsigned int.

ULONG_MAX

#define ULONG_MAX <#if expression >= 4,294,967,295>

The macro yields the maximum value for type unsigned long.

USHRT_MAX

#define USHRT_MAX <#if expression >= 65,535>

The macro yields the maximum value for type unsigned short.


See also the Table of Contents and the Index.

Copyright © 1989-2002 by P.J. Plauger and Jim Brodie. All rights reserved.

[Previous] [Contents] [Next]