Gray Code Converter
Input
Binary value
Gray: g = b XOR (b >> 1); adjacent values differ in one bit, so an absolute encoder read during a transition is off by at most one step. Decoding XORs all higher bits.
4-bit table (decimal · binary · Gray)
000000000
100010001
200100011
300110010
401000110
501010111
601100101
701110100
810001100
910011101
1010101111
1110111110
1211001010
1311011011
1411101001
1511111000