<limits.h>

<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>

#define LLONG_MAX <#if expression >= 9,223,372,036,854,775,807> [added with C99]
#define LLONG_MIN <#if expression <= -9,223,372,036,854,775,807> [added with C99]
#define ULLONG_MAX <#if expression >= 18,446,744,073,709,551,615> [added with C99]

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:

  • SCHAR_MIN if char represents negative values
  • zero otherwise

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.

LLONG_MAX

#define LLONG_MAX <#if expression >= 9,223,372,036,854,775,807> [added with C99]

The macro yields the maximum value for type long long.

LLONG_MIN

#define LLONG_MIN <#if expression <= -9,223,372,036,854,775,807> [added with C99]

The macro yields the minimum value for type long long.

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.

ULLONG_MAX

#define ULLONG_MAX <#if expression >= 18,446,744,073,709,551,615> [added with C99]

The macro yields the maximum value for type unsigned long long.

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 © 1992-2006 by P.J. Plauger and Jim Brodie. All rights reserved.

Last modified: 2013-12-21

comments powered by Disqus