Making a particular bit "0" in C++
This question already has an answer here:
Just use :
p = p & ~(1u<<3);
What happens here ?
1. (1u<<3) 0...01000
2. ~(1u<<3) 1...10111 // Invert the bits
3. p & ~(1u<<3) *****0*** // Here * means the bit representation of p
That's how the bit changes to 0.
Hope it helps :)
上一篇: th比特为零?
下一篇: 在C ++中创建一个特殊的位“0”