Binary Codes
Binary Codes
Outline
• Codes
• Types of Codes
• Weighted
• Non-Weighted
Introduction
• In the coding, when numbers, letters or words are
represented by a specific group of symbols, it is said
that the number, letter or word is being encoded.
The group of symbols is called as a code.
•The digital data is represented, stored and
transmitted as group of binary bits. This group is
also called as binary code.
•The binary code is represented by the number as
well as alphanumeric letter.
Advantages of Binary Code
Following is the list of advantages that binary code
offers.
•Binary codes are suitable for the computer
applications.
•Binary codes are suitable for the digital
communications.
•Binary codes make the analysis and designing of
digital circuits if we use the binary codes.
•Since only 0 & 1 are being used, implementation
becomes easy.
Classification of Binary Code
The codes are broadly categorized into following
four categories:
• Weighted Codes
• Non-Weighted Codes
• Binary Coded Decimal Code
• Alphanumeric Codes
• Error Detecting Codes
• Error Correcting Codes
Classification of Binary Code
Weighted Codes
Weighted binary codes are those binary codes which
obey the positional weight principle. Each position of
the number represents a specific weight. Several
systems of the codes are used to express the decimal
digits 0 through 9. In these codes each decimal digit
is represented by a group of four bits.
Non-Weighted Codes
0000 1100
0100
0001 0101
1101
0011
0001 0111
1111
0010
0000 0110
1110
0010
0110 0010
1010
0111
0011 0011
1011
0101
0001 0001
1001
0100
0000 0000
1000
1 0 1 1 0 Binary 1 0 1 1 0 Binary
1 1 1 0 Gray 1 1 1 0 1 Gray
(10110)2 = (11101)Gray
Binary-to-Gray Code Conversion
22
Gray-to-Binary Conversion
23
MSB of gray code is MSB of binary.
Other bits of binary code are obtained by XOR
operation of generated binary bit with next bit of gray
code.
Example: Convert Gray code 11011 to binary.
1 1 0 1 1 Gray 1 1 0 1 1 Gray 1 1 0 1 1 Gray
1 Binary 1 0 Binary 1 0 0 Binary
1 1 0 1 1 Gray 1 1 0 1 1 Gray
1 0 0 1 Binary 1 0 0 1 0 Binary
(11011)Gray = (10010)2
Gray-to-Binary Conversion
24
Application of Gray code
25
Parity bit.
Even parity: additional bit supplied to make total number of ‘1’s
even.
Odd parity: additional bit supplied to make total number of ‘1’s
odd.
Character ASCII Code
Example: Odd parity. 0 0110000 1
1 0110001 0
... ...
Parity bits
9 0111001 1
: 0111010 1
A 1000001 1
B 1000010 1
... ...
Z 1011010 1
[ 1011011 0
\ 1011100 1
Error Detection Codes
32
Parity bit can detect odd number of errors but not even
number of errors.
Example: For odd parity numbers,
10011 10001 (detected)
10011 10101 (non detected)
Row-wise parity
Error Detection Codes
33