Gray Code Tool

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.

✓ Gray Code Input ✓ Exact Binary Result ✓ XOR Breakdown ✓ Decimal Verification ✓ Free Unlimited Use
G→B
Gray Code → Binary
● Ready
Enter a Gray code using only binary digits 0 and 1. Spaces are ignored.
Try:
✓ Binary Result
Ordinary binary representation
Gray Bits 0
Binary Bits 0
Decimal Value 0
XOR Conversion Steps

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.

The first bit is copied: B₀ = G₀ Every following bit is: Bᵢ = Bᵢ₋₁ XOR Gᵢ

Example: Convert Gray Code 1110 to Binary

Gray code: 1 1 1 0 Step 1: First binary bit = first Gray bit B₀ = 1 Step 2: 1 XOR 1 = 0 Step 3: 0 XOR 1 = 1 Step 4: 1 XOR 0 = 1 Therefore: 1110 Gray = 1011 Binary Decimal verification: 1011₂ = 11₁₀

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: 1xxx Binary must begin: 1xxx

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.

Important: the decimal preview uses integer conversion and may become visually large for long bit strings, while the binary result itself remains exact.

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?
Copy the first Gray bit as the first binary bit. Then XOR each Gray bit with the previous binary result to obtain the next binary bit.
What is Gray code 11 in binary?
The first bit is 1. Then 1 XOR 1 = 0, so Gray 11 converts to binary 10.
What is Gray code 10 in binary?
Gray 10 converts to binary 11.
What is Gray code 1110 in binary?
Gray 1110 converts to binary 1011.
Why is XOR used for Gray-to-binary conversion?
Each binary bit after the first is determined by whether the previous binary bit and current Gray bit are different.
Is the first Gray bit always the same as the first binary bit?
Yes. The most significant bit is copied directly.
Is Gray code the same as binary?
No. Both use 0 and 1, but they encode numeric sequences differently.
Why is Gray code useful?
Adjacent Gray values differ by only one bit, which can reduce ambiguity during physical or asynchronous transitions.
Can Gray code contain digits other than 0 and 1?
No. Standard binary-reflected Gray code uses only binary digits 0 and 1.
Can this calculator handle long Gray codes?
Yes. Conversion is performed directly on the bit string using the Gray-to-binary XOR rule.
Does BinaryCon already have binary-to-Gray conversion?
Yes. BinaryCon’s existing Binary to Gray Converter performs the reverse direction.
Does BinaryCon require registration?
No. The Gray Code to Binary Converter can be used directly without signup.
Scroll to Top