C limits (limits.h) Library
C limits Constants
The <limits.h> header has constants with the smallest and largest values that each integer type can store.
Example
Print the smallest and largest values of an int:
printf("%d\n", INT_MIN);
printf("%d\n", INT_MAX);
The values can be different on different systems. The table shows the values on most computers today:
| Constant | Description | Value |
|---|---|---|
| CHAR_BIT | The number of bits in a char (one byte) |
8 |
| SCHAR_MIN | The smallest value of signed char |
-128 |
| SCHAR_MAX | The largest value of signed char |
127 |
| UCHAR_MAX | The largest value of unsigned char |
255 |
| CHAR_MIN | The smallest value of char |
-128 or 0 |
| CHAR_MAX | The largest value of char |
127 or 255 |
| SHRT_MIN | The smallest value of short |
-32768 |
| SHRT_MAX | The largest value of short |
32767 |
| USHRT_MAX | The largest value of unsigned short |
65535 |
| INT_MIN | The smallest value of int |
-2147483648 |
| INT_MAX | The largest value of int |
2147483647 |
| UINT_MAX | The largest value of unsigned int |
4294967295 |
| LONG_MIN | The smallest value of long |
-2147483648 (4 bytes) or -9223372036854775808 (8 bytes) |
| LONG_MAX | The largest value of long |
2147483647 (4 bytes) or 9223372036854775807 (8 bytes) |
| ULONG_MAX | The largest value of unsigned long |
4294967295 (4 bytes) or 18446744073709551615 (8 bytes) |
| LLONG_MIN | The smallest value of long long |
-9223372036854775808 |
| LLONG_MAX | The largest value of long long |
9223372036854775807 |
| ULLONG_MAX | The largest value of unsigned long long |
18446744073709551615 |
Note: The smallest value of an unsigned type is always 0, so there is no UINT_MIN.
C float.h Constants
The <float.h> header has constants for the decimal types float and double.
Example
Print how many digits float and double can store correctly:
printf("%d\n", FLT_DIG);
printf("%d\n", DBL_DIG);
| Constant | Description | Value |
|---|---|---|
| FLT_DIG | The number of decimal digits that a float stores correctly |
6 |
| FLT_EPSILON | The difference between 1 and the next float value |
1.192093e-07 |
| FLT_MIN | The smallest positive normal float value |
1.175494e-38 |
| FLT_MAX | The largest float value |
3.402823e+38 |
| DBL_DIG | The number of decimal digits that a double stores correctly |
15 |
| DBL_EPSILON | The difference between 1 and the next double value |
2.220446e-16 |
| DBL_MIN | The smallest positive normal double value |
2.225074e-308 |
| DBL_MAX | The largest double value |
1.797693e+308 |
Note: <float.h> has the same constants for long double, with LDBL_ in front, like LDBL_MAX.
Related Pages
Read more about data types in our C Data Types Tutorial and C Decimal Precision Tutorial.