Cool_Breeze 发表于 2020-4-15 10:48:35

输出每个地址(BIT)上面的值!

#include <stdio.h>
typedef unsigned int uint;
int main(void)
{
        uint i=123;
        uint j=123<<16;
        uint k=2570;
        j+=k;
        int a=0;
        for (a=31;a>=0;a--)
        {
                if (a==15) putchar('\n');
                printf("%d",(j&1<<a) != 0);//先位移后与;右到左;
        }
        putchar('\n');
        printf("j = %d\n",j);
        printf("i = %d\n",i);
        printf("k = %d\n",k);
        printf("j>>16 = %d\n",j>>16);
        printf("j&65535 = %d\n",j&65535);
        getchar();
        return 0;
}
0000000001111011
0000101000001010
j = 8063498
i = 123
k = 2570
j>>16 = 123
j&65535 = 2570


--------------------------------
Process exited after 27.19 seconds with return value 0
请按任意键继续. . .

Cool_Breeze 发表于 2020-8-21 08:39:51

运算符的优先级和结合性
页: [1]
查看完整版本: 输出每个地址(BIT)上面的值!