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.
All processing happens on the client-side, locally in your browser. No data is uploaded.
Paste Decimal numbers below (1 per line if multiple)
Gray Code numbers
History
- 2018-02-05Tool Launched
Background
Decimal
Decimal is the numeric system most used by us humans. It consists of the Hindu-Arabic numerals, a set 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 using these steps:-
-
Convert the input decimal to binary
-
Take the first bit of the binary input and write it to the output
-
Repeat the following steps 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
-
Write this result to the output. So,
0 + 0 = 0,0 + 1 = 1,1 + 0 = 1and1 + 1 = 0.
Example Decimal to Gray Code Conversion
Let's say your Decimal value is 173,
and you want to convert it to its gray code form.
-
Step 1:
Convert the input decimal to binary. So,
173becomes10101101 -
Step 2:
Take the first bit of the binary input and write it to the output. Output is
1 -
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
-
Take the second bit of the input and XOR it to the previous bit of the input.
-
Step 4:
So, our final gray code result is:
11111011
Gray Code Table
| Decimal | Hex | Binary | Gray Code |
|---|---|---|---|
| 0 | 0 | 0000 | 0000 |
| 1 | 1 | 0001 | 0001 |
| 2 | 2 | 0010 | 0011 |
| 3 | 3 | 0011 | 0010 |
| 4 | 4 | 0100 | 0110 |
| 5 | 5 | 0101 | 0111 |
| 6 | 6 | 0110 | 0101 |
| 7 | 7 | 0111 | 0100 |
| 8 | 8 | 1000 | 1100 |
| 9 | 9 | 1001 | 1101 |
| 10 | a | 1010 | 1111 |
| 11 | b | 1011 | 1110 |
| 12 | c | 1100 | 1010 |
| 13 | d | 1101 | 1011 |
| 14 | e | 1110 | 1001 |
| 15 | f | 1111 | 1000 |