Gray code

Gray Code, named after Frank Gray of Bell Labs, is a series of bytes or words where each byte/word in the series differs from the preceding BY ONLY ONE BIT. Example: 0, 1, 3, 2, 6, 7. These patterns have been used for testing logic circuits, communication transmissions, machine learning in AI, etc.

Generate a Gray Code pattern for values from 0 to 255:

FOR i = 0 TO 255
gray = i XOR (i \ 2) 'or (INT(i / 2))
' ...Here you print or output successive Gray Code values in GRAY.

Credit: Moneo, Agamemnus

GenerateGrayCode - page last edited 2004-01-29 10:28:56 by (home) (edit)
Blast WIKI - by RoboticBoy - edited and tweaked for our evil purposes by Hexadecimal Disaster