嵌入式软件工程师&&太极拳
全部博文(548)
分类:
2011-02-20 20:08:40
#includeint main(void) { int a = 0xff; printf("a = %#x \n", a); //11111111 printf("a = %#x \n", a >> 1); //01111111 printf("a = %#x \n", a >>= 1); //01111111 // ^a = a >> 1; printf("a = %#x \n", a >>= 1); //00111111 printf("a = %#x \n", a >>= 1); //00011111 printf("a = %d \n", a <<= 1); // << 1 ==> *2^1 printf("a = %d \n", a <<= 1); // << 2 ==> *2^2 printf("a = %d \n", a <<= 1); a = 0xffff; printf("a = %#x \n", ~a); //0xffff0000 a = 0x35; //00110101 printf("a = %#x \n", a | 0x18); //00011000 //00111101 a = 0x35; //00110101 printf("a = %#x \n", a & 0x18); //00011000 //00010000 a = 0x35; //00110101 printf("a = %#x \n", a ^ 0x18); //00011000 //00101101 0x2d a = 0x35; printf("a = %#x \n", a | 0x80); //10110101 printf("a = %#x \n", a |= (1 << 7)); //置1; // ^ a = a | (1 << 7) // printf("a = %#x \n", a & (0 << 7)); //0 printf("a = %#x \n", a & 0x7f); //01111111 printf("a = %#x \n", a & ~(1 << 7)); //清0; // 取出某一位; printf("a = %#x \n", a & (1 << 7)); //值为真; 该位有数; return 0; }