Last active
July 20, 2016 11:26
-
-
Save vetras/317fa445049b8ae9e78e to your computer and use it in GitHub Desktop.
Play with bits in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set bit X to 1 : number |= 1 << x; | |
Set bit X to zero : number &= ~(1 << x); | |
Toggle bit X : number ^= 1 << x; | |
Checking the value of bit X : value = number & (1 << x); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment