Generate the full decimal-binary-Gray table for 2 to 6 bits. Every row differs from the next in exactly one Gray bit, including the wrap-around – the property that defines the code.
Show calculation steps
Processed privately in your browser β nothing you paste is uploaded, logged or stored.
The whole sequence at once
Single conversions prove a value; the table proves the PROPERTY. Every row of a Gray sequence differs from the next in exactly one bit β including the wrap from last row to first β and generating 2 to 6 bits of it makes the claim checkable by eye.
Each row is computed live: index β fixed-width binary β g = b β (b >> 1). Nothing is pasted; the table is the formula, tabulated.
Worked slice (3-bit)
Dec Binary Gray 0 000 000 1 001 001 2 010 011 3 011 010 4 100 110 β binary flips 3 bits here; Gray flips 1 5 101 111 6 110 101 7 111 100 β wraps to 000 with one bit change β
Reading the table like an engineer
The binary column shows WHERE multi-bit transitions cluster (every power-of-two boundary); the Gray column shows them eliminated. Row 3β4 is the classic: 011β100 versus 010β110. That one comparison is the entire sales pitch for the code.
Choosing a width
Match the resolution of the device: 16-position encoder β 4 bits, 64-position β 6. The generator caps at 6 bits (64 rows) for on-page readability; the construction itself extends indefinitely.
Privacy
Rows are generated in your browser at click time β no fetching, no transmission.
How to use the Gray Code Table Generator
- Choose the bit width – 2 to 6 bits (4 to 64 rows).
- Click "Generate table".
- Each row lists decimal, weighted binary and Gray code.
- Scan any adjacent pair – including last back to first – and exactly one Gray bit differs.
Frequently asked questions
What does the table demonstrate?
The defining single-change property across an ENTIRE counting cycle – each row differs from the next in one Gray bit, and the wrap-around row pair obeys it too, making the code cyclic.
Why is the cyclic property important?
Rotary encoders wrap from the highest position to zero physically; a code that violated the property at the seam would glitch once per revolution. Reflected Gray code closes the loop cleanly.
How is each row computed?
Index β binary at the chosen width β g = b β (b >> 1). The table is generated fresh from those formulas, so it is verifiable rather than pasted.
What width should I choose for my encoder?
Match the encoder's stated resolution: 16 positions β 4 bits, 64 β 6. Wider tables exist conceptually but 6 bits (64 rows) is the practical ceiling for on-page reading.
Can I use the table for Karnaugh maps?
Yes – K-map row/column headers follow 2-bit Gray order (00 01 11 10) so adjacent cells differ in one variable; the 2-bit table IS that ordering, and larger widths generalise it.
Why do the binary and Gray columns start and end alike?
Row 0 is all zeros in both (XOR of zeros is zero), and the top Gray bit always equals the top binary bit – the columns agree on the leading bit of every row by construction.
Does generation happen locally?
Yes – the rows are computed in your browser at click time; nothing is fetched or sent.