DIGITAL · TOOL

Gray Code Converter

Binary ⇄ Gray code — adjacent values differ by only one bit.

Basic No backend · 100% client-side

What it does: Convert between binary and Gray code.

When to use it: When building encoders, ADCs or state machines that need to avoid race conditions.

→ Gray 00000110
Next

You might also need

How to

How to use the Gray code converter

Pick a direction and enter a value.

  1. 01

    Pick a direction

    Binary → Gray or Gray → Binary.

  2. 02

    Enter a decimal value

    Type the number to convert (the "source" for the chosen direction).

  3. 03

    Read both codes

    Both the binary and Gray code bit strings are shown at once.

FAQ

Common questions, answered in 3 minutes

What is Gray code used for?

Adjacent values differ by only one bit. Used in rotary encoders, ADCs and state machines, it avoids the transient glitch codes caused by several bits flipping at once.

How do I get Gray code from binary?

g = n XOR (n shifted right by 1 bit). The most significant bit stays the same; every other bit is XORed with the bit above it.

Can you do arithmetic in Gray code?

Not directly. You usually convert back to binary, compute, then convert the result to Gray.

Data Provenance

Standards and sources referenced by this tool

Item Value / Formula Source
Gray code g = n XOR (n>>1) Reflected binary code

Exact via BigInt, no external API.

⚡ Powered by Circflow