Binary codes are the group of symbols which are used to encode the numbers, alphabets or special characters by using a group of bits. This group of bits is known as binary codes.
Classification of binary codes
The following figure shows the classification of binary codes.
In this code, each digit position of the number represents a specific weight. In weighted code, each decimal digit is represented by a group of four bits and each bit has a weight 8, 4, 2, 1.
There are different Binary coded Decimal(BCD) like 8421 code, 2421 code, 3321 code, 4221 code, 5211 code which comes under weighted code. For example, let us consider a decimal number 25, for which the equivalent binary number in 8421 code is as follows
In this code, no weight is assigned to any of the bit positions. Bits will not have any fixed value based on their position. Excess-3 code and gray code are the examples of non-weighted code.
It is a non-weighted code and known as unit-distance code. This is because, bit patterns for every consecutive number differ in only one bit position. These codes are also called cyclic codes.
The following table shows the gray code, in which you can find that, the two consecutive or two adjacent number differ only in one bit position.
How to find a gray code from the given binary number?
- Write the MSB of the given binary code as the MSB of gray code and binary code are same.
- Perform an Ex-OR operation with the previous bit and the current bit to get the next gray digit. Ignore the carry, if any.
- Repeat 2nd step until all the binary bits have been Ex-ORed with their previous one.
Let us look at an example here. Convert a binary number (101011)2 into its equivalent gray code.
A code is said to be reflective, if the code for any number is the complement of any another number.
For example, the code for 9 is 1111, whereas the code for 0 is 0000. Since 1111 and 0000 are complement of each other, the number 9 and 0 are said to be reflective codes.
In sequential codes, each succeeding code is one binary number greater than its preceding code, which greatly helps in manipulation of mathematical data. 8421 and excess-3 codes are sequential codes but 2421 and 5211 are not sequential codes.
As the name suggests, the codes which consists of both numbers and alphabetic characters are called alphanumeric codes. These codes consists of symbols to represent the 26 alphabets(including capital and small letter), 0-9 numbers and other symbols. Most commonly used alphanumeric codes are.
- ASCII(American Standard code for Information Interchange) – 7 bit code
- EBCDIC (Extended Binary Coded Decimal Interchange Code) – 8 bit code
- Hollerith code
Error detecting and correcting codes
Whenever a digital information is transmitted in a binary form from one network or device to other network, there is a possibility of error to occur. This error means, the signal corresponding to 0 may change to 1 or the signal corresponding to 0 may change to 1 due to the some disturbances.
In order to main the data integrity between transmitter and receiver, an extra bit or more than one bit is added with the transmitted data. This extra bit is use to detect and correct the error that takes place in the data. the extra bit with the data, together constitute the code. There are codes which are used only to detect the error and are known as error detecting codes and there are codes which assist in detection and correction of errors are known as error detecting and correcting codes.