The neighbors in Gray code
问题 Is there any algorithm that I can use to find the neighbors in Gray code? For small numbers is just fine to write the entire table, but if I have a number like 010 110 is a bit to much to write the entire grey code table with 6 numbers. 回答1: Copied shamelessly from Wikipedia: /* The purpose of this function is to convert an unsigned binary number to reflected binary Gray code. The operator >> is shift right. The operator ^ is exclusive or. */ unsigned int binaryToGray(unsigned int num) {