下面程序当输入10时,为什么会输出-11,请指点#include<stdio.h>#include<conio.h>#include<stdlib.h>
int main(void){ int num,reverse;
scanf("%d",&num); reverse=~num; printf("reverse=%d\n",reverse); getch(); exit(0);}
10 → 0000 0000 0000 1010 (假设int为两字节)~10→ 1111 1111 1111 0101 (补码)→1000 0000 0000 1011 (原码-11)
1111 1111 1111 0101 (补码)→1000 0000 0000 1011 (原码-11)这是怎么回事?