2
Binary Codes
The present chapter is an extension of the previous chapter on number systems. In the previous
chapter, beginning with some of the basic concepts common to all number systems and an outline
on the familiar decimal number system, we went on to discuss the binary, the hexadecimal and
the octal number systems. While the binary system of representation is the most extensively used
one in digital systems, including computers, octal and hexadecimal number systems are commonly
used for representing groups of binary digits. The binary coding system, called the straight binary
code and discussed in the previous chapter, becomes very cumbersome to handle when used to
represent larger decimal numbers. To overcome this shortcoming, and also to perform many other
special functions, several binary codes have evolved over the years. Some of the better-known binary
codes, including those used efficiently to represent numeric and alphanumeric data, and the codes
used to perform special functions, such as detection and correction of errors, will be detailed in this
chapter.
2.1 Binary Coded Decimal
The binary coded decimal (BCD) is a type of binary code used to represent a given decimal number
in an equivalent binary form. BCD-to-decimal and decimal-to-BCD conversions are very easy and
straightforward. It is also far less cumbersome an exercise to represent a given decimal number in
an equivalent BCD code than to represent it in the equivalent straight binary form discussed in the
previous chapter.
The BCD equivalent of a decimal number is written by replacing each decimal digit in the integer
and fractional parts with its four-bit binary equivalent. As an example, the BCD equivalent of (23.15) 10
is written as (0010 0011.0001 0101) BCD . The BCD code described above is more precisely known
as the 8421 BCD code, with 8, 4, 2 and 1 representing the weights of different bits in the four-bit
groups, starting from MSB and proceeding towards LSB. This feature makes it a weighted code,
which means that each bit in the four-bit group representing a given decimal digit has an assigned
Digital Electronics: Principles, Devices and Applications Anil K. Maini
© 2007 John Wiley & Sons, Ltd. ISBN: 978-0-470-03214-5
Binary Codes
The present chapter is an extension of the previous chapter on number systems. In the previous
chapter, beginning with some of the basic concepts common to all number systems and an outline
on the familiar decimal number system, we went on to discuss the binary, the hexadecimal and
the octal number systems. While the binary system of representation is the most extensively used
one in digital systems, including computers, octal and hexadecimal number systems are commonly
used for representing groups of binary digits. The binary coding system, called the straight binary
code and discussed in the previous chapter, becomes very cumbersome to handle when used to
represent larger decimal numbers. To overcome this shortcoming, and also to perform many other
special functions, several binary codes have evolved over the years. Some of the better-known binary
codes, including those used efficiently to represent numeric and alphanumeric data, and the codes
used to perform special functions, such as detection and correction of errors, will be detailed in this
chapter.
2.1 Binary Coded Decimal
The binary coded decimal (BCD) is a type of binary code used to represent a given decimal number
in an equivalent binary form. BCD-to-decimal and decimal-to-BCD conversions are very easy and
straightforward. It is also far less cumbersome an exercise to represent a given decimal number in
an equivalent BCD code than to represent it in the equivalent straight binary form discussed in the
previous chapter.
The BCD equivalent of a decimal number is written by replacing each decimal digit in the integer
and fractional parts with its four-bit binary equivalent. As an example, the BCD equivalent of (23.15) 10
is written as (0010 0011.0001 0101) BCD . The BCD code described above is more precisely known
as the 8421 BCD code, with 8, 4, 2 and 1 representing the weights of different bits in the four-bit
groups, starting from MSB and proceeding towards LSB. This feature makes it a weighted code,
which means that each bit in the four-bit group representing a given decimal digit has an assigned
Digital Electronics: Principles, Devices and Applications Anil K. Maini
© 2007 John Wiley & Sons, Ltd. ISBN: 978-0-470-03214-5
