Skip to main content

Gray code compared with binary numbers

Short answer

Gray code is an unweighted code where successive values differ by only one bit. Compared to binary: binary is weighted and used for arithmetic but may change many bits at transitions (e.g., 3→4 changes 3 bits); Gray is unweighted, minimizes transition errors, but is not suitable for arithmetic. Example: (0111)₂ → Gray (0100).

What is a gray code? Compare with binary numbers.

Gray code is an unweighted, reflected binary code in which successive numbers differ in only one bit position. It is used in shaft position encoders, K-maps and ADCs to avoid errors during transitions.

DecimalBinaryGray
0000000
1001001
2010011
3011010
4100110
5101111
6110101
7111100

Comparison with binary numbers

PointBinaryGray
TypeWeighted (positional)Unweighted
Change between successive valuesMany bits may change (3 → 4: 011 → 100)Only one bit changes
ArithmeticEasy to add and subtractNot suitable for arithmetic
Error at transitionsFalse readings possibleVery small error
Conversion—Gi=Bi+1⊕BiG_i = B_{i+1} \oplus B_i

Example: (0111)2(0111)_2 → Gray (0100)(0100).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 1 questions →