Skip to content

Instantly share code, notes, and snippets.

@pftbest
Created July 19, 2017 21:00
Show Gist options
  • Select an option

  • Save pftbest/eda06c809883b73695b2602f00123538 to your computer and use it in GitHub Desktop.

Select an option

Save pftbest/eda06c809883b73695b2602f00123538 to your computer and use it in GitHub Desktop.
static const uint8_t reverse_lookup[16] = {
0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf,
};
uint8_t reverse_bits(uint8_t n)
{
return (reverse_lookup[n & 0xf] << 4) | reverse_lookup[n >> 4];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment