Original Post
while fiddling around with binary numbers and gray code, I derived a simple function for converting binary numbers to gray code numbers g(b) = b XOR (b>>1) recursively calling g(b) eventually returns b again. The number of recursive calls m is 2n where n is the largest integer value such that 2^(2^n) is less than b. So that would be floor(log2log2b). I just think that going from the binary number to the gray code number is really simple (one call of g(b)) and using the same function you could get back to the binary number (eventually). Anyone else having fun with mathness? [Edited by - capn_midnight on January 19, 2005 6:54:58 PM]