要想判断int类型的取值范围,首先要知道:
1.int类型所占字节数;
2.整型变量数据在内存中以什么方式存储;
获得int型所占字节数
#include<stdio.h>
int main()
{
printf("%d\n",sizeof(int));
return 0;
}
结果:
得到int所占字节数为4;
又得知
整型数据在内存中是以补码的方式存储;
所以当数据>=0时,原码 = 反码 = 补码;
数值范围为 0 ~ 2^31 - 1;
#include<stdio.h>
#includ