C++中的整形字节数

2022-07-22 09:42:37

目录整形short、int、long、longlong规定如下以64位win7系统为例32位程序整形数据类型表示的范围64位程序整形数据类型表示的范围头文件climits定义了符号常量整形short...

目录
整形short、int、long、long long规定如下
以64位win7系统为例
32位程序整形数据类型表示的范围
64位程序整形数据类型表示的范围
头文件climits定义了符号常量

整形short、int、long、long long规定如下

short至少16位
int至少与short一样长
long至少32位,且至少与int一样长
long long至少64位,且至少与long一样长

以64位win7系统为例

类型字节数(byte)char1short2int4long4long long8

32位程序整形数据类型表示的范围

(32位与64位区别在于long 和unsigned long的字节数不同)

C数据类型最小值最大值char-128127unsigned char0255short-3 27683 2767unsigned short06 5535int-21 4748 364821 4786 3647unsigned int042 9496 7295long-21 4748 364821 4786 3647unsigned long042 9496 7295int32_t-21 4748 364821 4786 3647uint32_t-21 4748 364821 4786 3647int64_t-922 3372 0368 5477 5808922 3372 0368 5477 5807uint64_t01844 6744 0737 0955android 1615

64位程序整形数据类型表示的范围

C数据类型最小值最大编程值char-128127unsigned char0255short-3 27683 2767unsigned short06 5535int-21 4748 364821 4786 3647unsigned int042 9496 7295long-922 3372 0368 5477 5808922 3372 0368 5477 5807unsigned long01844 6744 0737 0955 1615int32_t-21 4748 364821 4786 3647uint32_t-21 4748 364821 4786 3647int64_t-922 3372 0368 5477 5808922 3372 0368 5477 5807uint64_t01844 6744 0737 0955 1615

头文件climits定义了符号常量

如下表所示:

符号常量表示CHAR_BITchar的位数CHAR_MAXchar的最大值CHAR_MINchar的最小值SCHR_MAXsigned char的最大值SCHAR_MINsigned char的最小值UCHAR_MAXunsigned char的最大值SHTR_MAXshort的最大值SHRT_MINshort的最小值USHRT_MAXunsigned short的最大值INT_MAXint的最大值INT_MINint的最小值UINT_MAXunsigned int的最大值pythonLONG_MAXlong的最大值LONG_MINlong的最小值ULONG_MAXunsigned long的最大值LLONG_MAXlong long的最大值LLONG_MINlong long的最小值ULLONG_MAXunsigned long long的最大值

以上为个人经验,希望能给大家一个参考,也希望大家多多支持我们。