INT_MIN
is a macro that expands to the smallest (most negative) value that can be stored in a variable of type int
.INT_MAX
is a macro that expands to the largest (most positive) value that can be stored in an int
.
On most processors
INT_MIN == -INT_MAX - 1
, i.e., there is one more negative number than positive number in the range of legal values.
For
unsigned int
, the corresponding values are 0
and UINT_MAX
. Typically UINT_MAX == 2*INT_MAX+1
.
There are similar constants for other numeric types in C. Be careful with floating-point values, though, as
FLT_MIN
is the smallest positive float
value and DBL_MIN
is the smallest positive double
. Similarly FLT_MAX
and DBL_MAX
are the largest finite values that can be represented in a float
or double
, even though both types can usually represent infinity.
Comments
Post a Comment