A couple of points of interest regarding Gray codes. First, Gray codes are not unique. That is, for a given number of bits in the binary representation, there is generally more than one Gray code sequence corresponding to the sequence of n-bit integers. Of course, the successive elements of every such Gray code differ by just one bit. With regard to algorithms, here are two schemes. b(i) and g(i) refer to the i-th bit of the n-bit binary and Gray-code representations, respectively. The symbol X stands for exclusive OR. Binary to Gray-code conversion: g(i) = b(i) X b(i+1) where i = 0,1,2,...n-1 g(n) = b(n) Gray-code to binary conversion: b(n) = g(n) b(i) = g(i) X b(i+1) where i = n-1,...2,1,0 Note that because b(i+1) is required to evaluate b(i) in this Gray-code to binary conversion, i should be stepped from the high end toward zero as indicated. Obviously, these schemes can be implemented very easily in either software or hardware. --- Warren Davis ================================================ Davis Associates, Inc. 43 Holden Road West Newton, MA 02165 U.S.A. Tel: 617-244-1450 FAX: 617-964-4917 Visit our web site at: http://www.davis-inc.com ================================================