类型名称 字节数 取值范围
signed char 1 -128~+127
short int 2 -32768~+32767
int 4 -2147483648~+2147483647
long int 4 -2147483648~+2141483647
long long long int 8 -9223372036854775808~+9223372036854775807
编译器不同,所占字节宽度是不相同,分别如下:
16位编译器:
int: 2个字节
long: 4个字节
long long: 8个字节
unsigned long: 4个字节
32位编译器:
int: 2个字节
long: 4个字节
long long: 8个字节
unsigned long: 4个字节
64位编译器:
int: 4个字节
long: 8个字节
long long: 8个字节
unsigned long: 8个字节
unsigned int (unsigned long)
4字节8位可表达位数:2^32=42 9496 7296
范围:0 ~ 42 9496 7295 (42*10^8) int (long)
4字节8位可表达位数:2^32=42 9496 7296
范围:-21 4748 3648 ~ 21 4748 3647 (21*10^8) long long (__int64)
8字节8位可表达位数:2^64=1844 6744 0737 0960 0000
范围:-922 3372 0368 5477 5808 ~ 922 3372 0368 5477 5807 (922*10^16) unsigned long (unsigned __int64)
8字节8位可表达位数:2^64=1844 6744 0737 0960 0000
范围:0 ~ 1844 6744 0737 0955 1615 (1844*10^16)