Created
November 26, 2014 10:45
-
-
Save tailnode/7356579379c650c50e6a to your computer and use it in GitHub Desktop.
按二进制格式颠倒各个位顺序:0xAA(10101010) -> 0x55(0x01010101)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int revert(unsigned char data) | |
{ | |
const unsigned char table[] = {0, 2, 1, 3}; | |
unsigned int revert = (table[data >> 6]) | (table[(data & 0x30) >> 4] << 2) | |
| (table[(data & 0x0c) >> 2] << 4) | (table[data & 0x03] << 6); | |
return revert; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment