toggle a bit code example
Example: toggling setting clearing checking changing a bit in c
// Setting a bit
number |= 1UL << n;
// Clearing a bit
number &= ~(1UL << n);
// Toggling a bit
number ^= 1UL << n;
// Checking a bit
bit = (number >> n) & 1U;
// Changing the nth bit to x
number ^= (-x ^ number) & (1UL << n);