๐Ÿ”ฒ Gray Code Converter

Input value (decimal)90
Gray code01110111
Output value (decimal)119

Convert a binary number to standard reflected binary Gray code, or convert Gray code back to binary. Gray code has the property that adjacent values differ by only one bit, which is used in rotary encoders and digital circuits to prevent errors.

How to use

  1. Choose "binary to Gray" or "Gray to binary" mode.
  2. Enter a bit string made of 0s and 1s.
  3. The converted value and its decimal equivalent are shown automatically.

FAQ

What is Gray code?

Itโ€™s a standard bit representation called reflected binary code, where adjacent values differ by exactly one bit. Itโ€™s used in rotary encoders, Karnaugh maps, and similar applications.

What formula does this use?

Binary to Gray uses gray = binary XOR (binary >> 1). The reverse conversion iteratively XOR-folds the Gray code bits from the most significant bit down, the standard method.

What does the 3-bit Gray code sequence look like?

It goes 000, 001, 011, 010, 110, 111, 101, 100 โ€” the standard reflected binary sequence.