Skip to content

Instantly share code, notes, and snippets.

@mhagrelius
Created October 3, 2019 18:11
Show Gist options
  • Save mhagrelius/8a7f45bbf4ba78caf350a24eb9098db3 to your computer and use it in GitHub Desktop.
Save mhagrelius/8a7f45bbf4ba78caf350a24eb9098db3 to your computer and use it in GitHub Desktop.
Useful bit manipulation functions
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