Convert Gray code to binary instantly with this accurate and user-friendly online converter. Just input your Gray code and get the equivalent binary output in seconds.
Convert Gray Code to Binary
Enter a sequence of Gray codes in the converter to get the corresponding binary representation.
How to Convert Gray Code to Binary
Gray Code to Binary Conversion Formula
There’s a simple method to convert a Gray code number into binary:
- The most significant bit (MSB) of the binary number is the same as the MSB of the Gray code.
- For the remaining bits:
- Binary bit = Previous binary bit ⊕ Current Gray bit
(⊕ = XOR operation)
- Binary bit = Previous binary bit ⊕ Current Gray bit
What is Gray code?
A Gray code is a binary numeral system where two successive values differ by only one bit. Converting Gray code to binary involves a specific algorithm.
Gray Code to Binary Conversion Algorithm:
The most significant bit (MSB) of the binary code is the same as the MSB of the Gray code. Each subsequent binary bit is obtained by XORing the current Gray code bit with the previous binary bit.
Mathematically:
- Bn=GnBn=Gn (MSB is the same)
- Bi=Gi⊕Bi+1Bi=Gi⊕Bi+1 for i=n−1i=n−1 down to 00
Truth Table (4-bit Gray Code to Binary)
Below is the truth table for a 4-bit Gray code to binary conversion, along with the conversion steps.
Gray (G₃ G₂ G₁ G₀) | Binary (B₃ B₂ B₁ B₀) | Conversion Steps |
---|---|---|
0000 | 0000 | B3=G3=0B3=G3=0 B2=G2⊕B3=0⊕0=0B2=G2⊕B3=0⊕0=0 B1=G1⊕B2=0⊕0=0B1=G1⊕B2=0⊕0=0 B0=G0⊕B1=0⊕0=0B0=G0⊕B1=0⊕0=0 |
0001 | 0001 | B3=0B3=0 B2=0⊕0=0B2=0⊕0=0 B1=0⊕0=0B1=0⊕0=0 B0=1⊕0=1B0=1⊕0=1 |
0011 | 0010 | B3=0B3=0 B2=0⊕0=0B2=0⊕0=0 B1=1⊕0=1B1=1⊕0=1 B0=1⊕1=0B0=1⊕1=0 |
0010 | 0011 | B3=0B3=0 B2=0⊕0=0B2=0⊕0=0 B1=1⊕0=1B1=1⊕0=1 B0=0⊕1=1B0=0⊕1=1 |
0110 | 0100 | B3=0B3=0 B2=1⊕0=1B2=1⊕0=1 B1=1⊕1=0B1=1⊕1=0 B0=0⊕0=0B0=0⊕0=0 |
0111 | 0101 | B3=0B3=0 B2=1⊕0=1B2=1⊕0=1 B1=1⊕1=0B1=1⊕1=0 B0=1⊕0=1B0=1⊕0=1 |
0101 | 0110 | B3=0B3=0 B2=1⊕0=1B2=1⊕0=1 B1=0⊕1=1B1=0⊕1=1 B0=1⊕1=0B0=1⊕1=0 |
0100 | 0111 | B3=0B3=0 B2=1⊕0=1B2=1⊕0=1 B1=0⊕1=1B1=0⊕1=1 B0=0⊕1=1B0=0⊕1=1 |
1100 | 1000 | B3=1B3=1 B2=1⊕1=0B2=1⊕1=0 B1=0⊕0=0B1=0⊕0=0 B0=0⊕0=0B0=0⊕0=0 |
1101 | 1001 | B3=1B3=1 B2=1⊕1=0B2=1⊕1=0 B1=0⊕0=0B1=0⊕0=0 B0=1⊕0=1B0=1⊕0=1 |
1111 | 1010 | B3=1B3=1 B2=1⊕1=0B2=1⊕1=0 B1=1⊕0=1B1=1⊕0=1 B0=1⊕1=0B0=1⊕1=0 |
1110 | 1011 | B3=1B3=1 B2=1⊕1=0B2=1⊕1=0 B1=1⊕0=1B1=1⊕0=1 B0=0⊕1=1B0=0⊕1=1 |
1010 | 1100 | B3=1B3=1 B2=0⊕1=1B2=0⊕1=1 B1=1⊕1=0B1=1⊕1=0 B0=0⊕0=0B0=0⊕0=0 |
1011 | 1101 | B3=1B3=1 B2=0⊕1=1B2=0⊕1=1 B1=1⊕1=0B1=1⊕1=0 B0=1⊕0=1B0=1⊕0=1 |
1001 | 1110 | B3=1B3=1 B2=0⊕1=1B2=0⊕1=1 B1=0⊕1=1B1=0⊕1=1 B0=1⊕1=0B0=1⊕1=0 |
1000 | 1111 | B3=1B3=1 B2=0⊕1=1B2=0⊕1=1 B1=0⊕1=1B1=0⊕1=1 B0=0⊕1=1B0=0⊕1=1 |
Summary:
- The MSB (B₃) is always the same as G₃.
- Each subsequent bit is computed as Bi=Gi⊕Bi+1Bi=Gi⊕Bi+1.
This truth table and algorithm can be extended to any number of bits.
Gray Code to Binary Conversion Examples
1. Convert 11100 Gray code to binary?
To convert Gray code 11100
to binary:
- First binary bit (MSB) is the same:
1
- Next bits:
- 2nd: 1 ⊕ 1 = 0
- 3rd: 0 ⊕ 1 = 1
- 4th: 1 ⊕ 0 = 1
- 5th: 1 ⊕ 0 = 1
Binary result: 10111
2. Convert 1110
Gray code to binary
To convert Gray code 1110
to binary:
- MSB =
1
- 2nd: 1 ⊕ 1 = 0
- 3rd: 0 ⊕ 1 = 1
- 4th: 1 ⊕ 0 = 1
Binary result: 1011
4. What is the binary equivalent of the Gray code 110011?
To convert Gray code 110011
to binary:
- MSB =
1
- 2nd: 1 ⊕ 1 = 0
- 3rd: 0 ⊕ 0 = 0
- 4th: 0 ⊕ 0 = 0
- 5th: 0 ⊕ 1 = 1
- 6th: 1 ⊕ 1 = 0
Binary result: 100010
Also see: