Skip to content

Instantly share code, notes, and snippets.

@vetras vetras/bits.c
Last active Jul 20, 2016

Embed
What would you like to do?
Play with bits in C
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
You can’t perform that action at this time.