13-3. Negabinary Gray Code
If you write the integers in order in base −2, and convert them using the “shift and exclusive or” that converts to Gray from straight binary, you get a Gray code. The 3-bit Gray code has indexes that range over the 3-bit base −2 numbers, namely −2 to 5. Similarly, the 4-bit Gray code corresponding to 4-bit base −2 numbers has indexes ranging from −10 to 5. It is not a reflected Gray code, but it almost is. The 4-bit Gray code can be generated by starting with 0 and 1, reflecting this about a horizontal axis at the top of the list, and then reflecting it about a horizontal axis at the bottom of the list, and so on. It is cyclic.
To convert back to base −2 from this Gray code, the rules are of course the same as they ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access