C++ Reference: Standard C++ Library reference: C Library: climits

阚英睿
2023-12-01

C++官方参考链接:https://cplusplus.com/reference/climits/ 

头文件 
<climits> (limits.h)
整型的大小
此头文件为所使用的特定系统和编译器实现定义了具有基本整数类型限制的常量。
基本浮点类型的限制定义在<cfloat>(float.h)中。
宽度特定的整型和其他类型定义类型的限制定义在<cstdint>(stdint.h)中。

宏常量

nameexpressespossible value*
CHAR_BITNumber of bits in a char object (byte)8 or greater*
SCHAR_MINMinimum value for an object of type signed char-127 (-2^7+1) or less*
SCHAR_MAXMaximum value for an object of type signed char127 (2^7-1) or greater*
UCHAR_MAXMaximum value for an object of type unsigned char255 (2^8-1) or greater*
CHAR_MINMinimum value for an object of type chareither SCHAR_MIN or 0
CHAR_MAXMaximum value for an object of type chareither SCHAR_MAX or UCHAR_MAX
MB_LEN_MAXMaximum number of bytes in a multibyte character, for any locale1 or greater*
SHRT_MINMinimum value for an object of type short int-32767 (-2^15+1) or less*
SHRT_MAXMaximum value for an object of type short int32767 (2^15-1) or greater*
USHRT_MAXMaximum value for an object of type unsigned short int65535 (2^16-1) or greater*
INT_MINMinimum value for an object of type int-32767 (-2^15+1) or less*
INT_MAXMaximum value for an object of type int32767 (2^15-1) or greater*
UINT_MAXMaximum value for an object of type unsigned int65535 (2^16-1) or greater*
LONG_MINMinimum value for an object of type long int-2147483647 (-2^31+1) or less*
LONG_MAXMaximum value for an object of type long int2147483647 (2^31-1) or greater*
ULONG_MAXMaximum value for an object of type unsigned long int4294967295 (2^32-1) or greater*
LLONG_MINMinimum value for an object of type long long int-9223372036854775807 (-2^63+1) or less*
LLONG_MAXMaximum value for an object of type long long int9223372036854775807 (2^63-1) or greater*
ULLONG_MAXMaximum value for an object of type unsigned long long int18446744073709551615 (2^64-1) or greater*

*实际值取决于特定的系统和库实现,但应反映这些类型在目标平台的限制。 

兼容性
LLONG_MIN、LLONG_MAX和ULLONG_MAX是为符合1999年或以后的C标准(只包括2011年以后的C++标准:C++11)的库定义的。

 类似资料: