Gray Code

The GrayCode is an alternate bitwise representation system for numbers.

Normal Binary:

 0 0000
 1 0001
 2 0010
 3 0011
 4 0100
 5 0101
 6 0110
 7 0111
 8 1000 <- 4 bits change at the same time when moving from 7 to 8
 9 1001

Gray Codes:
 0 0000
 1 0001
 2 0011
 3 0010
 4 0110
 5 0111
 6 0101
 7 0100
 8 1100 <- only one bit changes when moving from 7 to 8
 9 1101

Gray codes are designed so that no more than one bit changes for each increment or decrement of a number.

This is useful in certain engineering, measurement, and hardware contexts. It is useful in measurement because even if the head is diagonal you are only off by one number. It is useful in hardware because if you try to read the number in normal binary while the bits are flipping, you might get a number that is wildly different, while the grey coded number will only be one off.



WikiStub


EditText of this page (last edited November 18, 2013) or FindPage with title or text search