C++ limits.h 头文件
Sizes of integral types
This header defines constants with the limits of fundamental integral types for the specific system and compiler implementation used.
The limits for fundamental floating-point types are defined in <cfloat> (<float.h>).
The limits for width-specific integral types and other typedef types are defined in <cstdint> (<stdint.h>).
Macro constants
name |
expresses |
value* |
CHAR_BIT |
Number of bits in a char object (byte) |
8 or greater* |
SCHAR_MIN |
Minimum value for an object of type signed char |
-127 (-27+1) or less* |
SCHAR_MAX |
Maximum value for an object of type signed char |
127 (27-1) or greater* |
UCHAR_MAX |
Maximum value for an object of type unsigned char |
255 (28-1) or greater* |
CHAR_MIN |
Minimum value for an object of type char |
either SCHAR_MIN or 0 |
CHAR_MAX |
Maximum value for an object of type char |
either SCHAR_MAX or UCHAR_MAX |
MB_LEN_MAX |
Maximum number of bytes in a multibyte character, for any locale |
1 or greater* |
SHRT_MIN |
Minimum value for an object of type short int |
-32767 (-215+1) or less* |
SHRT_MAX |
Maximum value for an object of type short int |
32767 (215-1) or greater* |
USHRT_MAX |
Maximum value for an object of type unsigned short int |
65535 (216-1) or greater* |
INT_MIN |
Minimum value for an object of type int |
-32767 (-215+1) or less* |
INT_MAX |
Maximum value for an object of type int |
32767 (215-1) or greater* |
UINT_MAX |
Maximum value for an object of type unsigned int |
65535 (216-1) or greater* |
LONG_MIN |
Minimum value for an object of type long int |
-2147483647 (-231+1) or less* |
LONG_MAX |
Maximum value for an object of type long int |
2147483647 (231-1) or greater* |
ULONG_MAX |
Maximum value for an object of type unsigned long int |
4294967295 (232-1) or greater* |
LLONG_MIN |
Minimum value for an object of type long long int |
-9223372036854775807 (-263+1) or less* |
LLONG_MAX |
Maximum value for an object of type long long int |
9223372036854775807 (263-1) or greater* |
ULLONG_MAX |
Maximum value for an object of type unsigned long long int |
18446744073709551615 (264-1) or greater* |
* the actual value depends on the particular system and library implementation, but shall reflect the limits of these types in the target platform.
Compatibility
LLONG_MIN, LLONG_MAX and ULLONG_MAX are defined for libraries complying with the C standard of 1999 or later (which only includes the C++ standard since 2011: C++11).
红色的是32位机的常用int型无穷大与无穷小。使用时只需要包含头文件,再直接引用以上符号就行了。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。