Bit position: 6543210
Starting bit pattern: ..............x...............
Bit mask: 000000000000001000000000000000
----------------------------------------- XOR
..............1...............
(Bit dnoted by . will remain unchaned)
|
i positions
<-------------->
1 << i = 000000..1000000000000000
|
int x; int i; x = x ^ (1 << i ); // Flip bit position i in x |
#define FLIPBIT( x, i ) ( x ^= (1 << i) ) |