Binary to Gray Code Conversion and Vice Versa

In this article, we will learn about the conversion of binary to Gray code and vice versa. You can refer to the gray code table, where we have already shown the gray codes of 3-bit numbers, that is, the decimal numbers from 0 to 7. In this article, we will learn the conversion techniques so that you can convert from binary to Gray or vice versa for any bit length.

Conversion from Binary to Gray Code

The following steps are followed to convert a binary number to a corresponding Gray code.

  • The most significant bit (left-most) in the Gray code is the same as the corresponding MSB in the binary number.
  • Going from left to right, add each adjacent pair of binary code bits to get the next Grey code bit. Discard carry.

Example: Convert the binary number 101110 to Gray code

Solution:

An example of conversion from binary to Gray

So, the final Gray code is 1011102 = 111001Gray

Learn about other code conversions:

  1. Number System Conversion
  2. BCD Code Conversion
  3. Excess-3 Code Conversion

Conversion from Gray Code to Binary

The following steps are followed to convert a Gray code to a corresponding binary number.

  • The most significant bit (left-most) in the binary code is the same as the corresponding MSB in the Gray code.
  • Add each binary code bit generated to the Gray code bit in the next adjacent position. Discard carries.

Example: Convert the Grey code 111001 to binary number

Solution:

An example of conversion from Gray to binary

So, the final binary number is 111001Gray = 1011102

Previous          Table of Content          Next

Leave a Reply

Your email address will not be published. Required fields are marked *