C正数负数的原码补码反码以及内存地址分析
#include<stdio.h> void swap(int a, int b); void main1(){ int i = 10; //正数的原码 00000000 00000000 00000000 0000 1010 //正数的补码 00000000 00000000 00000000 0000 1010 //正数的反码 00000000 00000000 00000000 0000 1010 //用16进制表示为: 000A printf("the address of i is %x ", &i); //0x0018FB20 这个地址每次都不一样,上面的值是000A getchar(); } void main(){ int i = -10; //负数的原码 10000000 00000000 00000000 0000 1010 //负数的补码 11111111 11111111 111111111 1111 0101 符号位不变其他位取反 //负数数的反码11111111 11111111 111111111 1111 0110 加1 //用16进制表示为: ff ff ff f6 printf("the address of i is %x ", &i); //内存地址是0x0018FAFC,上面的值是ff ff ff f6 getchar(); }