Last updated :
Posted :
The limits.h header, was defined as part of the c89 standard. It contains the min and the max limits, that integer types can have on a certain machine. The standard defines the minimum absolute value for the integer types, an implementation can define larger values.
The limits.h header, also defines the number of bits in a char, using the CHAR_BIT macro, and the maximum number of bytes in multibyte characters, using the MB_LEN_MAX macro.
The table below, shows the minimum absolute value, for the integer types, as defined by the c standard. An implementation can define larger values.
The limits header also define two macros, they are the:
An example of a limits.h header,
on a 64 bit system is:
#ifndef _LIMITS
#define _LIMITS
#define CHAR_BITS 8
/* Define the number of bits in a char */
#define MB_LEN_MAX 4
/* Define the max number of bytes that a
multibyte character can have for any
supported local .*/
#define SCHAR_MAX 127
#define SCHAR_MIN ( -127 - 1 )
/* Define the min and max values for
the signed char type .*/
#define UCHAR_MAX 255u
/* Define the max value for
the unsigned char type .*/
#define CHAR_MAX 127
#define CHAR_MIN ( -127 - 1 )
/* Define the min and max values for
the char type .*/
#define SHRT_MAX 32767
#define SHRT_MIN ( -32767 - 1 )
/* Define the min and max values
for the signed short type .*/
#define USHRT_MAX 65535u
/* Define the max value for the
unsigned short type .*/
#define INT_MAX 2147483647
#define INT_MIN ( -2147483647 - 1 )
/* Define the min and max values for the
int type .*/
#define UINT_MAX 4294967295U
/* Define the max value for the unsigned
int type .*/
#define LONG_MAX 9223372036854775807L
#define LONG_MIN (-9223372036854775807L - 1)
/* Define the min and max values for the
long type .*/
#define ULONG_MAX 18446744073709551615UL
/* Define the max value for the unsigned
long type .*/
#define LLONG_MAX 9223372036854775808LL
#define LLONG_MIN (-9223372036854775807LL - 1)
/* Define the min and max values for the
long long type .*/
#define ULLONG_MAX 18446744073709551615ULL
/* Define the max value for the unsigned
long long type .*/
#endif