Skip to content

Instantly share code, notes, and snippets.

@bit-hack
Created September 28, 2020 20:37
Show Gist options
  • Save bit-hack/928dfcd8919b320c393fdb4e458ecc8d to your computer and use it in GitHub Desktop.
Save bit-hack/928dfcd8919b320c393fdb4e458ecc8d to your computer and use it in GitHub Desktop.
Generate bit mask
// generate a bitmask between lo and hi bits inclusive
#define BIT_MASK(hi, lo) ((~0u >> (31-(hi))) & (~0u << (lo)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment