389 from Decimal to Gray Code

Converting a decimal number to Gray code involves converting the decimal number to binary first, then performing a binary-to-Gray-code conversion. Here's a step-by-step guide with an example for decimal number 389:

Step 1: Convert Decimal to Binary

Convert the decimal number 389 to binary:

38910 = 1100001012

Step-by-step converting 389 from decimal to binary

Step 1: Write Down the First Bit of the Gray Code

Write down the first bit of the Gray code as the same as the first bit of the binary number.

FIRST BIT OF GRAY CODE: 1

Step 2: perform the XOR operation of the first and the second bits of the binary number

The 1st bit is 1, and the 2nd bit is 1. These bits are the same, so the second bit of the Gray code is 0.

Step 3: perform the XOR operation of the second and the third bits of the binary number

The 2nd bit is 1, and the 3rd bit is 0. Both the bits are different, so the third bit of the Gray code is 1.

Step 4: perform the XOR operation of the third and the fourth bits of the binary number

The 3rd bit is 0, and the 4th bit is 0. These bits are the same, so the fourth bit of the Gray code is 0.

Step 5: perform the XOR operation of the fourth and the fifth bits of the binary number

The 4th bit is 0, and the 5th bit is 0. These bits are the same, so the fifth bit of the Gray code is 0.

Step 6: perform the XOR operation of the fifth and the sixth bits of the binary number

The 5th bit is 0, and the 6th bit is 0. These bits are the same, so the sixth bit of the Gray code is 0.

Step 7: perform the XOR operation of the sixth and the seventh bits of the binary number

The 6th bit is 0, and the 7th bit is 1. Both the bits are different, so the seventh bit of the Gray code is 1.

Step 8: perform the XOR operation of the seventh and the eighth bits of the binary number

The 7th bit is 1, and the 8th bit is 0. Both the bits are different, so the eighth bit of the Gray code is 1.

Step 9: perform the XOR operation of the eighth and the ninth bits of the binary number

The 8th bit is 0, and the 9th bit is 1. Both the bits are different, so the ninth bit of the Gray code is 1.

So, the Gray code for the decimal number389 is 101000111.
Decimal To Gray Code Converter



Other examples of Decimal to Gray Code conversion