Computer Codes:
The second category of codes are those codes which cannot be represented by any analytical relation, hence these codes are also called as nonanalytical code.NonAnalytical code. These are the following codes:
NonWeighted Codes:
Excess3 Codes, Gray Codes, BCD greater than 4bits
Self Complementing codes:
2421, 5211, Excess3 (XS3)
Sequential Codes:
8421 and XS3
Cyclic Code:
Gray Code
Reflecting Code:
Gray Code
Error Detection and Correcting Code:
Parity, Hamming Code
Gray Code
This code also known as a unit distance code. This code is best suited as a shat position encoder. Going from any one position to next position, there is only one bit change in the code. The pattern formed by the gray code is the mirror image, so the code is also called as reflected code. Figure shows the formation of gray code from 1bit to 2bits and from 2bit to 3bit.
Binary coded decimal(BCD) :
This code is an extension of decimal code. This code make use of 4bit binary code for decimal digit 0 through 9. As with 4bit, we can have 16 combinations, but the valid decimal digit symbols are from 0 to 9, code 1010 to 1111 are invalid code in BCD.
To encode in BCD, 4bit code of each decimal digit is written to form a valid binary equivalent
Examples
Decimal —–>  9  10  128  458  89 
BCD —–>  1001  0001 0000  0001 0010 1000  0100 0101 1000  1000 1001 
Self Complementing Codes
Excess3 (XS3) code:
An XS3 code is obtained by adding 3 with the equivalent decimal of a binary number and again converting it into binary number.
Procedure:
 Convert a binary to its decimal equivalent: e.g. 1001 = 9_{10}
 Add 3 to the decimal digit: in XS3, add 3, so 9+3=12.
 Convert the decimal back to binary : write the binary Code of 12, which is code of 9 in XS3
Binary  Decimal  +3  XS3 
0000  0  0+3 =3  0011 
0001  1  1+3=4  0100 
0010  2  2+3=5  0101 
0011  3  3+3=6  0110 
0100  4  4+3=7  0111 
0101  5  5+3=8  1000 
0110  6  6+3=9  1001 
0111  7  7+3=10  1010 
1000  8  8+3=11  1011 
1001  9  9+3=12  1100 
Conversion from bigger decimal numbers to XS3 is also simple:
 To each decimal digit, add 3
 Write equivalent binary code for each number so formed.
Example:
Decimal  4 8_{10}  920_{10}  73_{10} 
Add 3 to each digit  (4+3) (8+3)
7 11 
(9+3) (2+3) (0+3)
12 5 3 

XS3 Code  0111 1011  1100 0101 0011 
Advantage:
The primary advantage of XS3 coding over nonbiased coding is that a decimal number can be nines’ complemented (for subtraction) as easily as a binary number can be ones’ complemented; just invert all bits.
Self Complementing:
Excess3(XS3) code
Just complement the bits to get the 9’s complement
Decimal  6  9  1 
XS3 Code  1001  1100  0100 
Complement Bits  0110  0011  1011 
9’s complement
“(XS3) – 3” 
3  0  8 
Summary >  9’s complement of 6 is 3  9’s complement of 9 is 0  9’s complement of 1 is 8 
2421BCD:
The weight of the bits is 2, 4, 2, 1 and the numbers formed are:
2  4  2  1  
0  0  0  0  0 
1  0  0  0  1 
2  0  0  1  0 
3  0  0  1  1 
4  0  1  0  0 
5  0  1  0  1 
6  0  1  1  0 
7  0  1  1  1 
8  1  1  1  0 
9  1  1  1  1 
5421 Binary Coded Decimal Code
5  4  2  1  
0  0  0  0  0 
1  0  0  0  1 
2  0  0  1  0 
3  0  0  1  1 
4  0  1  0  0 
5  0  1  0  1 
6  0  1  1  0 
7  0  1  1  1 
8  1  0  1  1 
9  1  1  0  0 
10  1  1  0  1 
11  1  1  1  0 
12  1  1  1  1 
Quiz
 The BCD equivalent of decimal 648_{10} =
 XS3 equivalent of BCD 89_{10} =
 What is 2421 equivalent of 8 =
 What is the gray code equivalent of decimal 3………..
 Convert 1010 into gray code =………..