Free browser converter
Gray Code to Decimal Converter
Decode one reflected binary Gray code to its exact decimal integer using cumulative XOR, without Number precision loss.
Interactive tool
Decode Gray code to a decimal integer
Ready
Choose the exact data representation; the tool never guesses an encoding.
Detailed conversion guide
How to Convert Gray Code to Decimal
Recover the ordinary binary value with cumulative XOR. The most significant binary bit equals the first Gray bit; each later binary bit XORs the previous binary bit with the current Gray bit.
For Gray code 1111, the recovered binary bits are 1010. Binary 1010 equals decimal 10. BigInt keeps very long codes exact.
| Input | Output | Meaning |
|---|---|---|
0 | 0 | binary 0 |
1 | 1 | binary 1 |
1111 | 10 | binary 1010 |
1000 | 15 | binary 1111 |
Gray Code to Decimal with Cumulative XOR
Repeatedly XOR the Gray value with right-shifted copies until the shifted value reaches zero, then format the recovered binary value in base 10.
let gray = BigInt("0b" + bits);
let binary = gray;
for (let part = gray >> 1n; part; part >>= 1n) binary ^= part;
const decimal = binary.toString(10);Binary Syntax and Reflected Gray Code Scope
Only reflected binary Gray code is supported. The tool accepts 0 and 1, an optional leading 0b, and visual spaces or underscores.
This page does not decode arbitrary error-correcting codes or signed encodings. Invalid digits are rejected rather than stripped.
Related converters
Continue with related data converters
Choose the converter for the exact direction and representation you need.