0
$\begingroup$

I have a very poor understanding of gray code in general and I find it to be a difficult thing to learn. While trying to learn about it I stumbled upon this seemingly looking trivial question that I can't answer.

Can the bit pattern 01110011 represent offset gray-code?

What is "gray-code" and how do I construct it and recognize offset gray-code?

$\endgroup$
2
  • $\begingroup$ A Gray code is any binary number. It is impossible to distinguish it from another binary number that was generated otherwise. $\endgroup$ Commented Oct 18 at 12:18
  • $\begingroup$ Gray codes are a shuffling of the binary numbers of $n$ bits such that you only change one bit at a time. E.g. $000,001,010,011,100,101,110,111$ could become $000,001,011,010,110,111,101,100$. $\endgroup$ Commented Oct 18 at 12:21

2 Answers 2

0
$\begingroup$

Yes. Any bit pattern can represent an offset gray-code number. Gray code is an ordering of the binary numeral system such that two successive values differ in only one bit (binary digit).To fully understand it you need and example and compare with default binary. In binary:

1-> 0001  
2-> 0010   
3-> 0011

You can see that in binary when incrementing from 1 to 2, there are happening two bit operations. One is that the first bit turns off and second the 2'nd bit lights up. So this violates the rule of gray-code - "two successive values differ in only one bit".

In gray code it would look like this:

1-> 0001  
2-> 0011  
3-> 0010  

Can you see the difference? When we incremented from 1 to 2, the first bit didn't turned off anymore and the second lighted up. So only one bit operation happened.

You can also check out this article which has a C program that generates gray-codes between 1-32 bits. Using-Gray-Codes

$\endgroup$
0
$\begingroup$

The gray codes are designed to cover all possible bit patterns (of a given length). So 01110011 is perforce a gray code.

The purpose is to enumerate all patterns while changing a single bit at a time.

E.g. 000 001 011 010 110 111 101 100

You don't recognize a code in isolation, the sequence matters.


The reason these codes were invented is practical: if you change two bits or more at a time, for instance in a mechanical device, you are never sure that the changes are perfectly simultaneous and unwanted patterns can be generated transitorily.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.