Last active
April 26, 2019 23:08
-
-
Save justinmklam/bc802cdec18558dfe776cbeae6ac74e0 to your computer and use it in GitHub Desktop.
Cheat sheet for bitwise operations
This file contains hidden or 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 certain bits without affecting the rest. | |
// Clear all bits to a known value, then set them. | |
// newvalue must contain all bits | |
value = (value & ~mask) | (newvalue & mask); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment