Binary-code-lecture2
Binary-code-lecture2
• The binary code can be used for represent the number as well as alpha
numeric letters.
Classification of binary code
Binary code
Non weighted code Reflective code Sequential code Error detecting and
correcting code
•Example: •Example: •Example: •Example:
Gray 5211 8421 Hamming
Excess-3 2421 Excess-3
Weighted code Parity
Five bit BCD Excess-3
Binary • BCD
Ex: 0s1 Ex:
8421
2421
5211
4221
Binary code decimal (BCD)
0111 7
1000 8
1001 9
Gray code
• It is called cyclic or reflected code.
• In this code each code group does not differ from its
neighbour in more than one bit.
• Then add the binary digit from left to right at the adjacent position.
• Example:
Convert 15 into gray code.
+ + +
Left most bit 1 1 1 1
1 0 0 0
Solution:
+ + + + +
Left most bit 1 1 1 0 1 1
1 0 0 1 1 0
1. Write the left most bit as such.
2. Then add the binary digit from left to right at the adjacent position.
3. Write the digit which comes after addition.
3. Add this bit to the second left most bit, write the result,
discard carry.
Solution:
1 1 1 1
• Many applications of digital computers require the handling of data not only of numbers,
• The most commonly used character code is ASCII (the American Standard Code for
Information Interchange).
• ASCII represents each character with a 7-bit string, yielding a total of 128 characters.
• The code contains the uppercase and lower case alphabet, numeral, punctuation, and
– EBCDIC (Extended Binary Coded Decimal Interchange Code) uses 8 bits; used by
IBM mainframes. It is an extension of BCD code.
• During the processing or transmission of digital data a noise may change some bits from 0 to 1 or vice versa.
• A short duration noise can affect only a single bit causes a single-bit error.
• A long duration noise can affect two or more bits causes a multi-bit error.
Codes for detecting and correcting errors
• Error-detecting codes normally add extra information to the data.
• That is a code that uses n-bit strings need not contain 2n valid code words.
• An error-detecting code has the property that corrupting or garbling a code word will likely produce a bit string that is not a code word.
• Thus errors in a bit string can be detected by a simple rule - if it is not a code word it contains an error.
Parity check
• One of the most common ways to achieve error detection is by means of a parity bit.
• A parity bit is an extra bit included with a message to make the total number of 1’s transmitted either odd or even.
• If an odd parity is adopted, the P bit is chosen such that the total number of 1’s is odd.
Two dimensional codes
• LRC: Longitudinal Redundancy Checking
– LRC adds an additional character, the Block Check Character (BCC) to the end of the message or
block of data. The BCC uses parity on each bit position for each character in the message; in other words, by
determining parity on the first bit of each character and setting the first bit of the BCC to that value; then determining
D 1000100 1
A 1000001 1
T 1010100 0
A 1000001 1
BCC 1101111 1
Other codes
• Hamming codes - forward error correcting code
• CRC - cyclic-redundancy-check
• Checksum