The GRAY code:
It is a special type of binary code that is not weighted (the digits that make up the
code do not have an assigned weight). Its characteristic is that among a combination of digits
and the following, whether it is previous or subsequent, there is only a difference of one digit, changing
only one digit ensures fewer chances of error.. That is why it is also called code
progressive.
This progression also occurs between the last and the first combination. That is why it is
also called cyclic code. When a binary number goes from: 0111 to 1000 (from 7 to 8 in
decimal) or from 1111 to 0000 (from 16 to 0 in decimal) all the digits change. For the same case
but in Gray code: 0100 to 1100 (from 7 to 8 in decimal) or from 1000 to 0000 (from 16 to 0 in
decimal) has only changed one digit
Method to convert a binary number to GRAY
To convert a binary number to Gray code, the following method is followed: (analyze the
next graph
1. The number in binary is added to itself, but the second addend must be shifted one.
digit on the right. See the graph.
2. A binary addition is performed digit by digit without considering the carry, and the result is obtained.
total sum.
3. The last digit on the right side of the previous result is removed (the zero is removed that
it is in red), to obtain the GRAY code.
Method to convert GRAY code to binary
The first digit of the Gray code will be the same as that of the binary code.
2. If the second digit of the Gray code is '0', the second binary digit is equal to the first digit.
binary, if this digit is '1' the second binary digit is the inverse of the first binary digit.
If the third digit of the Gray code is '0', the third binary digit is equal to the second digit.
binary, if this digit is '1', the third binary digit is the inverse of the second binary digit..... and
so until finished.
Tabla comparativa entre los sistemas decimal, binario y Gray:
Decimal Binary Gray
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
16 10000 11000
17 10001 11001
18 10010 11011
19 10011 11010
20 10100 11110
21 10101 11111
22 10110 11101
23 10111 11100
24 11000 10100
25 11001 10101
26 11010 10111
27 11011 10110
28 11100 10010
29 11101 10011
30 11110 10001
31 11111 10000
32 100000 110000
33 100001 110001
34 100010 110011
35 100011 110010
36 100100 110110
37 100101 110111
38 100110 110101
39 100111 110100
40 101000 111100
41 101001 111101
42 101010 111111
43 101011 111110
44 101100 111010
45 101101 111011
46 101110 111001
47 101111 111000
48 110000 101000
49 110001 101001
50 110010 101011
51 110011 101010
52 110100 101110
53 110101 101111
54 110110 101101
55 110111 101100
56 111000 100100
57 111001 100101
58 111010 100111
59 111011 100110
60 111100 100010
61 111101 100011
62 111110 100001
63 111111 100000
64 1,000,000 1100000
65 1000001 1100001
66 1000010 1100011
67 C 1100010
68 D 1100110
69 101 g
70 110 101
71 G D
72 1001000 L
73 I 1101101
74 J O
75 K 1101110
76 L 1101010
77 M 1101011
78 N I
79 O 1101000
80 1010000 1111000
81 1010001 121
82 R 1111011
83 S 1111010
84 T 1111110
85 1010101 1111111
86 V 1111101
87 W 1111100
88 1011000 t
89 Y 117
90 1011010 119
91 1011011 v
92 L r
93 1011101 s
94 110 1110001
95 1111111 1110000
96 1100000 1010000
97 1100001 1010001
98 1100010 S
99 C R
100 D L
Operations in hexadecimal, octal, and base (3) system
Sums in hexadecimal:
6AE 4F1A5 1B90F AC839
+1FA + B8D5 + C44E +532DA
8A8 5AA7A 27D5D FFB13
Subtractions in hexadecimal:
A4FC9 27D5D 8A8 FFB13
- DE8 C44D 1FA -532DA
FFFFF FFFFF FFF FFFFF
-00DE8 -0C44D -1FA -532DA
FF217 F3BB1 E05 ACD25
A4FC9 27D5D 8A8 FFB13
+FF217 +F3BB1 +E05 +ACD25
1A41E0 11B90E 16AD 1AC838
A41E0 1B90E 6 AD AC838
+ 1 +1 +1 +1
A41E1 1B90F 6AE AC839
Addition in octal system:
767 654 763 631
+312 +731 +641 +432
1301 1605 1624 1263
Subtraction in octal:
1301 1605 1624 1263
767 - 731 -641 631
777 777 777 777
-767 731 -641 -631
010 046 136 146
1301 1605 1624 1263
+010 +046 +136 +146
1311 1653 1762 1431
311 653 762 431
+1 +1 +1 +1
312 654 762 432
Sums in base (3) system:
120 122 101
+111 +100 +121
1001 1022 222
Stay in base system (3):
1001 1022 121 212
111 222 010 -200
111 012
222 222
-111 222
111 000
1001 1022
+111 +000
1112 1022
112 022
+1 +1
120 100