Skip to main content

Gray vs binary code, convert (10110)₂ to Gray

Short answer

Gray code is unweighted; consecutive numbers differ in exactly one bit, unlike weighted binary where many bits can change. To convert (10110)₂ to Gray: keep MSB 1, then G₃=1⊕0=1, G₂=0⊕1=1, G₁=1⊕1=0, G₀=1⊕0=1 → (11101)Gray.

What is a Gray code? How is it different than binary code? Convert (10110)₂ to Gray code?

Gray code

Gray code is an unweighted binary code in which two successive values differ in only one bit. It is also called the reflected binary code. Example sequence: 000, 001, 011, 010, 110, 111, 101, 100.

Difference from binary code

PointBinary codeGray code
WeightsWeighted (1, 2, 4, 8…)Unweighted
Bit change between successive numbersOne or more (011 → 100 changes 3 bits)Exactly one
ArithmeticEasyNot suitable
Switching errorsPossible at transitionsMinimal
UsesComputation, storageEncoders, K-maps, ADCs

Convert (10110)2(10110)_2 to Gray

Keep the MSB; each following Gray bit is the XOR of two adjacent binary bits.

 Binary: 1   0   1   1   0
         | \ | \ | \ | \ |
 Gray  : 1   1   1   0   1
  • G4=B4=1G_4 = B_4 = 1
  • G3=1⊕0=1G_3 = 1 \oplus 0 = 1
  • G2=0⊕1=1G_2 = 0 \oplus 1 = 1
  • G1=1⊕1=0G_1 = 1 \oplus 1 = 0
  • G0=1⊕0=1G_0 = 1 \oplus 0 = 1

Answer: (10110)2=(11101)Gray(10110)_2 = (11101)_{Gray}

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 1 questions →