To Set / Clear and Toggle a single bit in C++ see the methods below.
Setting a bit
Use the bitwise OR operator (|) to set a bit.
number |= 1 << x;
Clearing a bit
Use the bitwise AND operator (&) to clear a bit.
number &= ~(1 << x);
Toggling a bit
The XOR operator (^) can be used to toggle a bit.
number ^= 1 << x;
RT @CodeSnippetsNET: How to Set / Clear and Toggle a single bit in C/C++ http://t.co/zM3DGzOuWM #programming #coding #code #dev #developer …
RT @CodeSnippetsNET: How to Set / Clear and Toggle a single bit in C/C++ http://t.co/zM3DGzOuWM #programming #coding #code #dev #developer …
RT @CodeSnippetsNET: How to Set / Clear and Toggle a single bit in C/C++ http://t.co/zM3DGzOuWM #programming #coding #code #dev #developer …
RT @CodeSnippetsNET: How to Set / Clear and Toggle a single bit in C/C++ http://t.co/zM3DGzOuWM #programming #coding #code #dev #developer …
RT @CodeSnippetsNET: How to Set / Clear and Toggle a single bit in C/C++ http://t.co/zM3DGzOuWM #programming #coding #code #dev #developer …
#cplusplus How to Set / Clear and Toggle a single bit in C and C++ http://t.co/Fr4RDc5cx6, see more http://t.co/CmFCXhlYml
RT @proteanthread: #cplusplus How to Set / Clear and Toggle a single bit in C and C++ http://t.co/Fr4RDc5cx6, see more http://t.co/CmFCXhlY…