Keywords |
  • High-Tech

Gray code

The Gray code is an unweighted digital code. Its main property is that two successive words in the code only differ in one bit, eliminating spurious states; advantage is taken of this coding adjacency to simplify the functions.

It is also called reflected binary code, and is simple to construct: Start at the right (the nth digit, dn). If its neighbour on its left, digit dn-1 is a 1, replace dn by 1-dn; otherwise leave it unchanged. Continue to the left, applying the same rules to each digit. The last digit d1 is kept the same since it is assumed to be a 0.

Example with 4 bits:

0 0000
1 0001
2 0011
3 0010
4 0110
5 0111
6 0101
7 0100



Fill out my online form.