Change a bit of an integer [duplicate]
You can set the fourth bit of a number by OR-ing it with a value that is zero everywhere except in the fourth bit. This could be done as x |= (1u << 3); Similarly, you can clear the fourth bit by AND-ing it with a value that is one everywhere except in the fourth … Read more