Tuesday, July 31, 2012

How do you flip bits on and off?

Use xor to flip between 1 and 0.  
x = x ^ 1;   // or x ^= 1;
This will change x alternately between 0 and 1.

No comments :