Gray Code (original) (raw)

Last Updated : 25 Apr, 2026

Gray code is a binary numbering system in which two consecutive values differ by only one bit, so it is also called reflected binary code or unit distance code; this single-bit change helps reduce errors during transitions, especially in digital and hardware systems, where normal binary counting may change multiple bits at once and cause ambiguity; in Gray code, the sequence is formed in such a way that the first half of the values is reflected in reverse order to generate the second half.

Characteristics and Properties of Gray Code

Types of Gray Codes

Conversion of Gray Code

Gray code and binary conversion are essential for understanding and resolving issues in digital systems. The most significant bit (MSB) of a binary integer is converted to gray code by taking the XOR of the bit that is now in use and the bit that is immediate to its left in the binary representation.

what-is-gray-code-1_480

n Bit Gray Code

The below table represents the gray code of decimals from 0 to 10.

**Decimal **Binary Code **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

To Generate Gray Code

Recursively, the prefix and reflect methods are used to create a number's Gray code. To create gray code:

what-is-gray-code-2

Generating Gray Code

Applications of Gray Code