LIMITS(3) | Library Functions Manual | LIMITS(3) |
The <limits.h> header has been standardized by at least three entities.
Constant | Type | Minimum value |
CHAR_BIT | char | 8 |
SCHAR_MAX | signed char | 127 |
SCHAR_MIN | signed char | -127 |
UCHAR_MAX | unsigned char |
255
|
INT_MAX | int | 32767 |
INT_MIN | int | -32767 |
UINT_MAX | unsigned int |
65535
|
SHRT_MIN | short | -32767 |
SHRT_MAX | short | 32767 |
USHRT_MAX | unsigned short |
65535
|
LONG_MAX | long int | 2147483647 |
LONG_MIN | long int | -2147483647 |
ULONG_MAX | unsigned long int |
4294967295
|
LLONG_MAX | long long int | 9223372036854775807 |
LLONG_MIN | long long int | -9223372036854775807 |
ULLONG_MAX | unsigned long long int |
18446744073709551615
|
MB_LEN_MAX | - | 1 |
All listed limits may vary across machines and operating systems. The standard guarantees only that the implementation-defined values are equal or greater in absolute value to those shown. The values permit a system with 16-bit integers using one's complement arithmetic.
Depending whether the system defines char as signed or unsigned, the maximum and minimum values are:
Constant | Type | Minimum value |
CHAR_MAX | char | either SCHAR_MAX or UCHAR_MAX |
CHAR_MIN | char | either SCHAR_MIN or 0 |
The two special cases, CHAR_BIT and MB_LEN_MAX, define the number of bits in char and the maximum number of bytes in a multibyte character constant, respectively.
As the limits are not necessary invariant, pathconf(2) and sysconf(3) should be used to determine the actual value of a limit at runtime. The manual pages of these two functions also contain a more detailed description of the limits available in NetBSD.
Richard W. Stevens and Stephen A. Rago, Advanced Programming in the UNIX Environment, Addison-Wesley, Second Edition, 2005.
August 9, 2011 | NetBSD 6.1 |