void show_bits(int n)
{
int i = 0;
for(i=0;i<32;i++)
printf("%d",(n&(1u<<(31-i)))!=0?1:0);
putchar('\n');
}
整数的原码 = 整数的补码
负数的补码:(原码)->(反码)->(反码+1)
负数的原码:(补码-1)->最高位符号位别动其余均转反码
void show_bits(int n)
{
int i = 0;
for(i=0;i<32;i++)
printf("%d",(n&(1u<<(31-i)))!=0?1:0);
putchar('\n');
}
整数的原码 = 整数的补码
负数的补码:(原码)->(反码)->(反码+1)
负数的原码:(补码-1)->最高位符号位别动其余均转反码
转载于:https://www.cnblogs.com/start2014/p/4005764.html