int类型应该是-32768~32767
因为0在原码中分为+0和-0 ,假设int是2个byte
则+0:0000000000000000
而-0:1000000000000000
取补码后
+0: 0000000000000000
-0 : 0000000000000000 (原码取反加一)
这样0在补码中只有一种
而任何数的原码在转成补码都不会是1000000000000000
所以补码中会比原码多一个编码10000000000000000
人为规定10000000000000000是-32768的编码
亲测:codeblocks
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX_INT ((unsigned)(-1) >> 1)
#define MIN_INT (MAX_INT + 1) int main() {
printf("%d %d",MAX_INT,MIN_INT);
return 0; }
**2147483647 -2147483648 Process returned 0 (0x0) execution time :
0.525 s Press any key to continue.**