求32位机器上unsigned int的最大值及int的最大值
#includeint main(int argc, char *argv[]){unsigned int max_int = (1编译后:int_sizeof1.c: 在函数‘main’中:int_sizeof1.c:5: 警告:整数溢出运行后:The max value of int on 32 machine: 2147483647
·
gcc编译后:
int_sizeof1.c: 在函数‘main’中:
int_sizeof1.c:5: 警告:整数溢出
运行后:
The max value of int on 32 machine: 4294967295
VC6.0和java编译后,无错误。
运行后:
The max value of int on 32 machine: 4294967295
将其int写成有符号型的程序如下:
gcc编译后:
int_sizeof1.c: 在函数‘main’中:
int_sizeof1.c:5: 警告:整数溢出
运行后:
The max value of int on 32 machine: 2147483647
VC6.0和java编译后,无错误。
运行后:
The max value of int on 32 machine: 2147483647
因为int的最高位是符号位。
更多推荐

所有评论(0)