Gray Code Decoder

Gray Code to Decimal Converter

Convert reflected binary Gray code directly to decimal. Enter a Gray code such as 1111 to recover its ordinary binary value, see the XOR decoding process, and calculate the exact decimal integer.

✓ Gray Code Input ✓ Binary Decoding ✓ Decimal Result ✓ XOR Steps ✓ Free Unlimited Use
G→10
Gray Code → Decimal
● Ready
Enter reflected binary Gray code using only digits 0 and 1. Spaces are ignored.
Try:
✓ Decimal Result
Decimal value represented by the Gray code
Binary Value 0
Gray Bits 0
Binary Bits 0
Gray-to-Binary Decoding Steps

What Is Gray Code to Decimal Conversion?

Gray code to decimal conversion decodes a reflected binary Gray code sequence into ordinary binary and then interprets that binary value as a base-10 integer.

Gray code cannot normally be read directly as an ordinary binary number because the same bit string may represent a different numerical value under Gray-code rules.

How to Convert Gray Code to Decimal

1. Start with Gray code

Write the Gray-code bits from left to right.

2. Copy the first bit

The first ordinary binary bit is identical to the first Gray bit.

3. Apply XOR

XOR the previous binary result with the next Gray bit.

4. Continue across all bits

Each new binary bit depends on the previous decoded binary bit.

5. Read the binary value

After processing every Gray bit, you have the ordinary binary representation.

6. Convert binary to decimal

Interpret the decoded binary sequence as a base-2 integer.

Gray Code to Binary Rule

If the Gray bits are represented by G and the decoded binary bits by B, the first bit is:

B₁ = G₁ Every later binary bit is calculated using: Bᵢ = Bᵢ₋₁ XOR Gᵢ

After the binary sequence is recovered, ordinary positional binary conversion gives the decimal value.

Example: Convert Gray Code 1111 to Decimal

Gray code: 1 1 1 1 Copy the first bit: B₁ = 1 Second binary bit: 1 XOR 1 = 0 Third binary bit: 0 XOR 1 = 1 Fourth binary bit: 1 XOR 1 = 0 Decoded binary: 1010 Convert binary to decimal: 1010₂ = 1×8 + 0×4 + 1×2 + 0×1 = 10 Therefore: 1111 Gray = 10₁₀

Example: Convert Gray Code 111 to Decimal

Gray: 111 Decode: First binary bit = 1 1 XOR 1 = 0 0 XOR 1 = 1 Binary result: 101 Decimal: 101₂ = 5₁₀ So: 111 Gray = 5 Decimal

Gray Code to Decimal Table

Gray Code Binary Decimal
000000000
000100011
001100102
001000113
011001004
011101015
010101106
010001117
110010008
110110019
1111101010
1110101111
1010110012
1011110113
1001111014
1000111115

Why Can’t Gray Code Be Converted Directly Like Binary?

Ordinary binary digits have positional weights such as 1, 2, 4, 8, and 16. Gray code does not use that same direct positional interpretation.

The Gray bits must first be decoded into ordinary binary before base-2 place values can be used to calculate the decimal integer.

Gray Code vs Binary Value

Bit Pattern If Read as Binary If Read as Gray
1111 15 10
111 7 5
11 3 2

The encoding convention therefore matters when interpreting the bits.

Why Is XOR Used?

In Gray decoding, each ordinary binary bit tells you the accumulated relationship between earlier Gray bits. XOR provides exactly the required rule:

0 XOR 0 = 0 0 XOR 1 = 1 1 XOR 0 = 1 1 XOR 1 = 0

Starting with the copied first bit, applying XOR repeatedly recovers the original binary sequence.

Gray Code Applications

Gray code is commonly associated with rotary encoders, position sensors, digital circuits, Karnaugh maps, counters, and systems where limiting transitions between neighboring encoded states can reduce ambiguity.

Can Long Gray Codes Be Converted?

Yes. The conversion algorithm works from left to right using simple XOR logic, so the binary bit string itself can be decoded without relying on ordinary 32-bit JavaScript bitwise arithmetic.

The final binary value is then interpreted using integer arithmetic to produce the decimal result.

Important: this converter treats the input as standard non-negative reflected binary Gray code. Other specialized Gray-code variants may use different conventions.

Common Gray Code to Decimal Mistakes

Reading Gray directly as binary

Gray bits must be decoded before applying ordinary binary positional weights.

XORing adjacent Gray bits

Each new binary bit uses the previous decoded binary bit and current Gray bit.

Changing the first bit

The most significant binary bit is copied directly from the first Gray bit.

Using OR instead of XOR

Gray-code decoding requires exclusive OR, not ordinary OR.

Related BinaryCon Tools

Gray Code to Decimal Converter FAQs

How do you convert Gray code to decimal?
First decode the Gray code into ordinary binary using the cumulative XOR rule, then convert that binary number into decimal.
What is Gray code 11 in decimal?
Gray 11 decodes to binary 10, which equals decimal 2.
What is Gray code 111 in decimal?
Gray 111 decodes to binary 101, which equals decimal 5.
What is Gray code 1111 in decimal?
Gray 1111 decodes to binary 1010, so its decimal value is 10.
Is Gray code 1111 equal to decimal 15?
No. That would be true if 1111 were interpreted as ordinary binary. As Gray code it represents decimal 10.
Why is the first Gray bit copied?
The most significant binary bit is identical to the most significant Gray bit, so decoding starts by copying it directly.
What XOR rule is used in Gray decoding?
Each binary bit after the first equals the previous decoded binary bit XOR the current Gray bit.
Can Gray code contain digits other than 0 and 1?
No. Standard reflected binary Gray code contains only binary digits 0 and 1.
Is Gray code the same as binary?
No. Gray code uses binary symbols but follows a different encoding sequence.
What is the reverse conversion?
Decimal to Gray Code Converter converts an ordinary decimal integer into the corresponding reflected Gray code.
Can this calculator handle long Gray-code inputs?
Yes. The Gray-to-binary conversion is performed directly on the bit string, and the final binary integer is converted to decimal using integer arithmetic.
Does BinaryCon require registration?
No. The Gray Code to Decimal Converter can be used directly without signup.
Scroll to Top