Created
December 25, 2018 02:29
-
-
Save kunigami/1a5efcf3a51008ae9b2952ee00824a8a 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
unsigned int v; | |
int r; | |
static const int MultiplyDeBruijnBitPosition[32] = | |
{ | |
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, | |
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 | |
}; | |
r = MultiplyDeBruijnBitPosition[((uint32_t)((v & -v) * 0x077CB531U)) >> 27]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment