Created
December 3, 2018 07:01
-
-
Save XcqRomance/c7075ed668e31e8bf73f0c9ce91e6448 to your computer and use it in GitHub Desktop.
颠倒二进制位
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
// 颠倒二进制位 | |
uint32_t reverseBits(uint32_t n) { | |
uint32_t m=0; | |
for(int i=0;i<32;i++){ | |
m<<=1; | |
m=m|(n&1); | |
//m<<=1; | |
n>>=1;//必须是这样的顺序,m左移32位,如果在下面,左移了33位; | |
} | |
return m; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment