Binary and Gray Code Conversion This below worksheet help you to understand how to perform Binary to Grey code and Grey to Binary code conversion. The grey code is a type of distance code also known as cyclic codes. In unit distance code the bit patterns for two consecutive numbers will differ in one bit position.
Lets Consider The Binary number B1 B2 B3 B4 ... Bn and the Gray code is G1 G2 G3 G4 ... Gn
Most significant bit (B1) is same as the most significant bit in Gray Code (B1 = G1)
To find next bit perform Ex-OR (Exclusive OR) between the Current binary bit and previous bit.
Gn = Bn (Ex-OR) Bn-1
Look the below Image for Binary to Gray code Conversion
Gray Code to Binary Conversion Follow the below steps to convert Gray Code to Binary
Most significant bit (G1) is same as the most significant bit in Binary Code (G1 = B1)
The next number can be obtain by taking Exclusive OR operation between the previous binary bit, and the current gray code bit and write down the value.
Repeat the Above Step until you find Bn Look at the below example for Converting Binary to Gray Code.