Binary to gray code
- First, write the binary code and copy down MSB. The MSB of gray and binary code are same.
- Then, add MSB and next lower significant bit and write down the addition of them.
- Continue the same process for all bits.
E.g. Find gray code for (1100)2
 Image may be NSFW.
Clik here to view.
List of gray codes of first 16 binary numbers.
BINARY |
GRAY |
0000 |
0000 |
0001 |
0001 |
0010 |
0011 |
0011 |
0010 |
0100 |
0110 |
0101 |
0111 |
0110 |
0101 |
0111 |
0100 |
1000 |
1100 |
1001 |
1101 |
1010 |
1111 |
1011 |
1110 |
1100 |
1010 |
1101 |
1011 |
1110 |
1001 |
1111 |
1000 |
Alternate method
There is an alternate method for finding gray code.
- Write down the binary code.
- Once again write the binary code starting from second MSB.
- Add both of them and ignore any carry in the process.Also ignore the LSB of the sum.
1 1 0 1
+ 1 1 0 1
1 0 1 1
Use the method you feel is simpler. Both of them will give correct gray code.
Source link
The post Binary to gray code conversion appeared first on Speak Electronics.