Gray code is a quasi-weight code. If the lowest bit of the Gray code is n=1, the absolute value of the Gray code weight is (2^n)-1, and its sign alternates between positive and negative from left to right. A typical Gray code is a single-step self-complementary code with reflection and cyclic characteristics. Its cyclic and single-step characteristics eliminate the possibility of major errors when randomly taking numbers, and its reflection and self-complementary characteristics make it very convenient to find the inverse. Gray code belongs to reliability coding and is a coding method that minimizes errors.
Decimal number | Natural binary number | Gray code |
0 | 0000 | 0000 |
1 | 0001 | 0001 |
2 | 0010 | 0011 |
3 | 0011 | 0010 |
4 | 0100 | 0110 |
5 | 0101 | 0111 |
6 | 0110 | 0101 |
7 | 0111 | 0100 |
8 | 1000 | 1100 |
9 | 1001 | 1101 |
10 | 1010 | 1111 |
11 | 1011 | 1110 |
12 | 1100 | 1010 |
13 | 1101 | 1011 |
14 | 1110 | 1001 |
15 | 1111 | 1000 |