char -128 ~ +127 (1 Byte)
short -32767 ~ + 32768 (2 Bytes)
unsigned short 0 ~ 65536 (2 Bytes)
int -2147483648 ~ +2147483647 (4 Bytes)
unsigned int 0 ~ 4294967295 (4 Bytes)
long == int
long long -9223372036854775808 ~ +9223372036854775807 (8 Bytes)
unsigned long long的最大值:1844674407370955161
double 1.7 * 10^308 (8 Bytes)
以上结果已经很明白了,补充说明下:
关于带符号与无符号类型:整型 int、stort 和 long 都默认为带符号型。要获得无符号型则必须制定该类型为unsigned,比如unsigned long。unsigned int类型可以简写为unsigned,也就是说,unsigned后不加其他类型说明符就意味着是unsigned int。

本文详细介绍了计算机中各种整数类型的取值范围及其所占字节数,包括char、short、int、long等,并解释了带符号与无符号类型的区别。
1920

被折叠的 条评论
为什么被折叠?



