Skip to content

Instantly share code, notes, and snippets.

@andrewhavck
Created October 3, 2012 01:20
Show Gist options
  • Save andrewhavck/3824355 to your computer and use it in GitHub Desktop.
Save andrewhavck/3824355 to your computer and use it in GitHub Desktop.
int clearBitsMSBthroughI(int num, int i) {
int mask = (1 << (i + 1)) - 1;
return num & mask;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment