Adjacent values in a reflected Gray-code sequence differ in only one bit. This is useful when several changing binary bits might otherwise be read inconsistently. For binary-to-Gray conversion, keep the most significant bit and XOR each adjacent pair of binary bits.
Worked example
Binary 1011 becomes Gray 1110: keep 1, then compute 1 XOR 0 = 1, 0 XOR 1 = 1, and 1 XOR 1 = 0. To reverse it, keep the first Gray bit, then cumulatively XOR each Gray bit with the previous recovered binary bit.
What to watch for
Gray code is an encoding, not a normal arithmetic representation. Its advantage applies to adjacent transitions, not arbitrary jumps between values.
Try it yourself
Convert binary 0110 to Gray.
Answer: Keep 0; adjacent XOR results are 1, 0 and 1. Therefore the Gray representation is 0101.
How to study this topic
Treat a code as a mapping with an explicit convention. Write the input, encoded bits and decoded result side by side. For error-checking examples, distinguish detecting an error from locating and correcting it.
Explore related programmes
These recorded programmes are upcoming. This article is general educational content, not a syllabus or course sample.
Digital Electronics