The ranges of the integer types are implementation-defined. The header <limits>
provides the std::numeric_limits<T>
template which provides the minimum and maximum values of all fundamental types. The values satisfy guarantees provided by the C standard through the <climits>
and (>= C++11) <cinttypes>
headers.
std::numeric_limits<signed char>::min()
equals SCHAR_MIN
, which is less than or equal to -127.std::numeric_limits<signed char>::max()
equals SCHAR_MAX
, which is greater than or equal to 127.std::numeric_limits<unsigned char>::max()
equals UCHAR_MAX
, which is greater than or equal to 255.std::numeric_limits<short>::min()
equals SHRT_MIN
, which is less than or equal to -32767.std::numeric_limits<short>::max()
equals SHRT_MAX
, which is greater than or equal to 32767.std::numeric_limits<unsigned short>::max()
equals USHRT_MAX
, which is greater than or equal to 65535.std::numeric_limits<int>::min()
equals INT_MIN
, which is less than or equal to -32767.std::numeric_limits<int>::max()
equals INT_MAX
, which is greater than or equal to 32767.std::numeric_limits<unsigned int>::max()
equals UINT_MAX
, which is greater than or equal to 65535.std::numeric_limits<long>::min()
equals LONG_MIN
, which is less than or equal to -2147483647.std::numeric_limits<long>::max()
equals LONG_MAX
, which is greater than or equal to 2147483647.std::numeric_limits<unsigned long>::max()
equals ULONG_MAX
, which is greater than or equal to 4294967295.std::numeric_limits<long long>::min()
equals LLONG_MIN
, which is less than or equal to -9223372036854775807.std::numeric_limits<long long>::max()
equals LLONG_MAX
, which is greater than or equal to 9223372036854775807.std::numeric_limits<unsigned long long>::max()
equals ULLONG_MAX
, which is greater than or equal to 18446744073709551615.For floating-point types T
, max()
is the maximum finite value while min()
is the minimum positive normalized value. Additional members are provided for floating-point types, which are also implementation-defined but satisfy certain guarantees provided by the C standard through the <cfloat>
header.
digits10
gives the number of decimal digits of precision.
std::numeric_limits<float>::digits10
equals FLT_DIG
, which is at least 6.std::numeric_limits<double>::digits10
equals DBL_DIG
, which is at least 10.std::numeric_limits<long double>::digits10
equals LDBL_DIG
, which is at least 10.min_exponent10
is the minimum negative E such that 10 to the power E is normal.
std::numeric_limits<float>::min_exponent10
equals FLT_MIN_10_EXP
, which is at most -37.std::numeric_limits<double>::min_exponent10
equals DBL_MIN_10_EXP
, which is at most -37.
std::numeric_limits<long double>::min_exponent10
equals LDBL_MIN_10_EXP
, which is at most -37.max_exponent10
is the maximum E such that 10 to the power E is finite.
std::numeric_limits<float>::max_exponent10
equals FLT_MIN_10_EXP
, which is at least 37.std::numeric_limits<double>::max_exponent10
equals DBL_MIN_10_EXP
, which is at least 37.std::numeric_limits<long double>::max_exponent10
equals LDBL_MIN_10_EXP
, which is at least 37.is_iec559
is true, the type conforms to IEC 559 / IEEE 754, and its range is therefore determined by that standard.