Skip to content

Instantly share code, notes, and snippets.

@Bigcheese
Created July 15, 2012 20:59
Show Gist options
  • Save Bigcheese/3118606 to your computer and use it in GitHub Desktop.
Save Bigcheese/3118606 to your computer and use it in GitHub Desktop.
unsigned char BitReverse(unsigned char val, unsigned char bits) {
unsigned char result = 0;
unsigned char i;
for (i = 0; i < bits; ++i) {
result += ((val >> (bits - i - 1)) & 1) << i;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment