Search code examples
gray-code

Why is gray code called reflected code?


I understand that each gray code differs from its preceding code by one bit, but i don't exactly understand why its called reflected. I came across this website https://www.pc-control.co.uk/gray_code.htm, where it says " The gray code is sometimes referred to as reflected binary, because the first eight values compare with those of the last 8 values, but in reverse order", but the first 8 gray codes are not comparable to the last 8 gray codes in reverse order as can be seen from the gray code table on their website. To add to my confusion the gray code table differs from the gray code table on my textbook, for eg gray code for 9 = 1000 on my textbook while on the website its 9 = 1101.


Solution

  • Consider the sequence on the linked page:

    0000
    0001
    0011
    0010
    0110
    0111
    0101
    0100
    1100
    1101
    1111
    1110
    1010
    1011
    1001
    1000
    

    Remove the most significant bit and you obtain a nice reflected sequence:

    x000
    x001
    x011
    x010
    x110
    x111
    x101
    x100
    -------- mirror
    x100
    x101
    x111
    x110
    x010
    x011
    x001
    x000
    

    Please note that the same kind of reflection can be found for Gray sequences of any width.