Gray Code to Binary Converter
Convert Gray code to ordinary binary instantly. Enter a Gray code value containing only 0 and 1 to recover the corresponding binary number, decimal value, and see the XOR conversion process bit by bit.
What Is Gray Code?
Gray code is a binary coding system in which two consecutive values differ by only one bit. It is also known as reflected binary code.
This one-bit-change property can reduce ambiguity during transitions in digital systems, position encoders, counters, and other hardware applications.
How to Convert Gray Code to Binary
1. Copy the first bit
The most significant binary bit is exactly the same as the first Gray code bit.
2. Move to the next Gray bit
Use the previously calculated binary bit together with the current Gray bit.
3. Apply XOR
XOR the previous binary bit with the current Gray bit.
4. Write the new binary bit
The XOR result becomes the next bit of the binary number.
5. Repeat across all bits
Continue from left to right until every Gray bit has been processed.
6. Read the binary result
The completed sequence is the ordinary binary representation.
Gray Code to Binary Formula
Let the Gray code bits be G and the resulting binary bits be
B.
Example: Convert Gray Code 1110 to Binary
Gray Code XOR Rules
| Previous Binary Bit | Current Gray Bit | Next Binary Bit |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Gray Code to Binary Examples
| Gray Code | Binary | Decimal |
|---|---|---|
0 |
0 |
0 |
1 |
1 |
1 |
11 |
10 |
2 |
10 |
11 |
3 |
110 |
100 |
4 |
111 |
101 |
5 |
101 |
110 |
6 |
100 |
111 |
7 |
1110 |
1011 |
11 |
Why Is the First Gray Bit Copied?
The most significant Gray bit and most significant binary bit are identical. There is no preceding binary bit available for XOR at the first position, so conversion begins by copying that bit directly.
Gray Code vs Ordinary Binary
| Feature | Gray Code | Ordinary Binary |
|---|---|---|
| Consecutive transitions | Usually one bit changes | Multiple bits may change |
| Arithmetic use | Not normally used directly | Standard binary arithmetic |
| Encoding purpose | Transition reliability | Numeric representation |
| Example for decimal 3 | 10 |
11 |
Why Gray Code Changes One Bit at a Time
Standard reflected Gray code is arranged so adjacent encoded values differ in only one position. This can reduce problems caused when several digital bits do not change at precisely the same instant.
That property makes Gray code useful in applications where transitions are measured physically or asynchronously.
Where Is Gray Code Used?
Gray code appears in rotary and linear position encoders, digital electronics, analog-to-digital conversion concepts, Karnaugh maps, communication systems, hardware counters, and other applications where minimizing transition ambiguity is useful.
Can Long Gray Codes Be Converted?
Yes. Gray-to-binary conversion requires only a left-to-right XOR chain. Each new binary bit depends on the previous binary bit and the current Gray bit.
The core conversion therefore works directly with the entered bit string rather than relying on ordinary floating-point arithmetic.
Common Gray Code Conversion Mistakes
XORing adjacent Gray bits
The next binary bit uses the previous binary result, not simply the previous Gray bit.
Changing the first bit
The first binary bit must be copied directly from the first Gray bit.
Using OR instead of XOR
Gray-to-binary conversion specifically uses exclusive OR.
Reading Gray code as ordinary binary
A Gray bit pattern does not usually represent the same value when interpreted directly as binary.
Related BinaryCon Tools
Gray Code to Binary Converter FAQs
How do you convert Gray code to binary?
What is Gray code 11 in binary?
1 XOR 1 = 0, so Gray
11 converts to binary 10.
What is Gray code 10 in binary?
10 converts to binary 11.
What is Gray code 1110 in binary?
1110 converts to binary 1011.