void disp_binary(unsigned u)
{
register int t;
for(t=128;t>0;t=t/2)
if(u & t) cout << "1";
else cout << "0";
}
128在内存中排列如下 0x 00 00 00 80,即最后一个字节的二进制排列如下1000 0000,每次除以2,1右移一位,用与运算获得输入参数中的指定位!
void disp_binary(unsigned u)
{
register int t;
for(t=128;t>0;t=t/2)
if(u & t) cout << "1";
else cout << "0";
}
128在内存中排列如下 0x 00 00 00 80,即最后一个字节的二进制排列如下1000 0000,每次除以2,1右移一位,用与运算获得输入参数中的指定位!