Created
December 14, 2016 06:21
-
-
Save catid/16972ad888bcf913321aaaf5acc00e19 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
// Get the next bit to flip to produce the 8-bit Gray code at the provided index | |
// Precondition: index > 0 and index < 256 | |
static int GetBitFlipForGrayCode8(int index) | |
{ | |
if (index & 1) | |
return 0; | |
if (index & 15) | |
return (0x6764 >> (index & 14)) & 3; | |
return ((0x12131210 >> (index >> 3)) & 3) + 4; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment