Binary Gray Code and Traditional Continuous Binary

zhaozj2021-02-16  49

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Gray Code continuous code

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

000 000

001 001

011 010

010 011

110 100

111 101

101 110

100 111

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Conversion:

Unsigned int bin_to_gray (unsigned int N)

{

Return n ^ (n >> 1);

}

Unsigned int gray_to_bin (unsigned int N)

{

INT I;

For (i = o; (1 << i)

{

N ^ = n >> (1 << i);

}

Return n;

}

转载请注明原文地址:https://www.9cbs.com/read-19237.html

New Post(0)