Created
October 3, 2019 18:11
-
-
Save mhagrelius/8a7f45bbf4ba78caf350a24eb9098db3 to your computer and use it in GitHub Desktop.
Useful bit manipulation functions
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
public static class BitManipulation | |
{ | |
public static bool CheckBitSet(int num, int bit) | |
{ | |
return ((num & (1 << bit)) != 0); | |
} | |
public static int SetBit(int num, int bit) | |
{ | |
return num | (1 << bit); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment