#include<stdio.h>
int main(void)
{
char i = 5; //101
char j = 6; //110
char k;
k = i & j; //100
printf("k = %d\n",k);
k = i && j; //k的值只能是真(1)或假(0);
printf("k = %d\n",k);
i = 3;
printf("~i : %d\n",~i);
i = 0x81; //1000 0001 → 0111 1110 → 0111 1111 → -127
printf(",,,%d\n",i); // -127
printf(">>1 : %d\n",i>>1); //1100 0000 → 0011 1111 → 0100 0000 -64
printf(">>2 : %d\n",i>>2); //1110 0000 → 0001 1111 → 0010 0000 -32
return 0;
}
郝斌的C语言基础 176 位运算符
最新推荐文章于 2024-08-16 21:54:14 发布