Re: Gray Code
- From: "eKo1" <berndlosert@xxxxxxxxxxxx>
- Date: 27 Sep 2006 12:14:09 -0700
I've never heard of 1, 2 and 4-bit reflections. I have heard of
reflections though which is pretty simple to explain: given a n-bit
string x_1x_2...x_n, it's reflection is x_n...x_2x_1.
This can be done by shifting the bits from one register to another. You
don't need XOR.
bwaichu@xxxxxxxxx wrote:
I am working my way through CRC32, and one implementation of CRC32 uses
Gray coding or reflected coding. Actually, upon examination, it looks
like openSSH uses Gray coding in it's CRC32 implementation.
Where I am stuck is with the binary math and the difference between 1,
2, and 4 bit reflections.
If I have the following , what would be it's 1, 2, and 4 bit
reflections?
1010-1111-0011
My understandings is that I XOR the right shifted value by the number
of bits:
1010-1111-0011 (n)
0101-0111-1001 (n >> 1)
----------------------
1111-1000-1010
So the above in C is:
n ^ ( n >> 1)
Is the above correct?
Also, what is meant by 1, 2, and 4 bit reflections? Am I shifting by
that many bits? I am not quite sure.
Thanks!
.
- References:
- Gray Code
- From: bwaichu@xxxxxxxxx
- Gray Code
- Prev by Date: Re: On the complexity of determining whether n numbers are distinct
- Next by Date: Re: On the complexity of determining whether n numbers are distinct
- Previous by thread: Gray Code
- Index(es):
Relevant Pages
|