Skip to content

Instantly share code, notes, and snippets.

@fahied
Created January 2, 2016 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fahied/be0eb7d5ef1342c115e9 to your computer and use it in GitHub Desktop.
Save fahied/be0eb7d5ef1342c115e9 to your computer and use it in GitHub Desktop.
Typical Bit Mask Operations
Typical Bit Mask Operations
Set a flag or overlay multiple values
flags | flagbitN
Unset a flag (zero-out a bit or set a bit to zero)
flags & ~flagbitN
Check if a bit is set
(flags & flagbitN) == flagbitN
Invert a pattern of bits
~flags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment