How can I set the least significant bit of an integer in C
This question already has an answer here:
To set bit 0 to one, use
int_var | 1
To reset bit 0 to zero, use
int_var & ~1
The operation in your example doesn't seem consistent:
10000011
10000010 & ~1
00000001 xor
00001011
00001011 nop
00000000 xor
01110011
01110010 & ~1
00000001 xor
11101100
11101101 & ~1
00000001 xor
11110101
11110100 & ~1
00000001 xor
01001011
01001010 & ~1
00000001 xor
01001010
01001010 nop
00000000 xor
01110100
01110100 nop
00000000 xor
链接地址: http://www.djcxy.com/p/28816.html
下一篇: 我如何设置C中整数的最低有效位