# Decimal to Gray Code Converter

Decimal to Gray Code Converter is used to convert a Decimal number into Gray Code format. Use the Gray Code Converter tool to convert between any number base and gray code.

##### Input: Paste Decimal numbers below (1 per line if multiple)

Background Information

### Decimal

Decimal is the numeric system most used by us humans. It comprises of 10 digits from 0 to 9.

### Gray Code

Gray Code also known as Reflected Binary Code is an ordering of binary numeral system used for error correction in digital terrestrial television and some cable TV systems.

### Conversion from Decimal to Gray Code

A Decimal can be converted to Gray Code in three steps:-

1. Convert the input decimal to binary
2. Take the first bit of the binary input and write it to the output
3. Repeat the following steps until you reach the end of the input
4. Take the second bit of the input and XOR it to the previous bit of the input
5. Write this result to the output. So, 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1 and 1 + 1 = 0.

#### Example Decimal to Gray Code Conversion

Let's say your Decimal value is 173 and you want to convert it to it's Gray Code form.

1. Step 1: Convert the input decimal to binary. So, 173 becomes 10101101
2. Step 2: Take the first bit of the binary input and write it to the output. Output is 1
3. Step 3: Repeat the steps below until you reach the end of the input
• Take the second bit of the input and XOR it to the previous bit of the input. 1 + 0 = 1
• Write the result to the output. Output: 11
• Take the third bit of the input and XOR it to the previous bit of the input. 0 + 1 = 1
• Write the result to the output. Output: 111
• Take the fourth bit of the input and XOR it to the previous bit of the input. 1 + 0 = 1
• Write the result to the output. Output: 1111
• Take the fifth bit of the input and XOR it to the previous bit of the input. 0 + 1 = 1
• Write the result to the output. Output: 11111
• Take the sixth bit of the input and XOR it to the previous bit of the input. 1 + 1 = 0
• Write the result to the output. Output: 111110
• Take the seventh bit of the input and XOR it to the previous bit. 1 + 0 = 1
• Write the result to the output. Output: 1111101
• Take the eighth (last) bit of the input and XOR it to the previous bit. 0 + 1 = 1
• Write the result to the output. Output: 11111011
4. Step 4: So, our final gray code result is: 11111011

### Gray Code Table

DecimalHexBinaryGray Code
0000000000
1100010001
2200100011
3300110010
4401000110
5501010111
6601100101
7701110100
8810001100
9910011101
10a10101111
11b10111110
12c11001010
13d11011011
14e11101001
15f11111000

#### George Plousos

• one year ago

Hi,

I was working in a different mathematical field. Unintentionally, I discovered two ways to convert numbers to Gray code. From right to left: I make the divisions of 173 with the numbers 2,4,8,16,32, ..., 256. I round each quotient to the nearest integer. I am writing this integer down from the corresponding fraction. If this integer is even, then I write below this digit 0, otherwise I write the digit 1. These digits form the Gray Code of 173:

173
_____________________________
256 128 64 32 16 8 4 2
1 1 3 5 11 22 43 87
1 1 1 1 1 0 1 1

Faster method. I can convert all numbers that have equal lengths of digits in the binary system to Gray codes. I do this without turning any number into binary. Here I find it difficult to present this method because it contains graphs, but you can find this here:

http://viXra.org/abs/2004.0456?ref=11278286

Feb 5, 2018
Tool Launched