Binary Coded Decimal – BCD
- Muhammad Shahid
- 43 Views
- 0 Comments
Binary Coded Decimal
The Binary Coded Decimal is a 4-bit binary number coded to represent specifically a decimal number. The “coded” refers to the process of assigning a specific or unique binary code to a particular decimal number. In the Binary Coded Decimal or shortly BCD, the decimal numbers from “0” to “9” are binary coded. The binary code representing each decimal number is called a Binary Coded Decimal. The Binary Coded Decimals are used in digital systems for displaying decimal values, mainly.
The decimal numbers use a base-10 numbering system and, as such, there are a total of ten (10) decimal numbers from “0” to “9”. Likewise, binary numbers use a base-2 numbering system. In order to code “0” to “9” decimal numbers in binary, ten (10) unique combinations of binary numbers are required, each representing a single decimal number. The number of combinations that can be produced by binary digits or bits (n) is given by 2n. The representation of ten (10) decimal numbers requires a binary code having at least four (4) binary digits or bits. The Binary Coded Decimal uses the minimalist bits’ option of four (4) to represent decimal numbers.
The famous Hexadecimal numbering system also uses the four (4) bits to represent equivalent binary numbers. The hexadecimal number uses a base-16 numbering system and there is a total of sixteen (16) hexadecimal numbers. The Binary Coded Decimals are similar to Hexadecimal numbers. However, Binary Coded Decimal (BCD) encoding uses only “0” to “9” numbers, and the rest of the numbers i.e. from “A” to “F” or from “10” to “15” are not required. The hexadecimal numbers from “0” to “9” are similar to the binary coded decimals, “0” to “9”, respectively.
The usage of Binary Coded Decimals to represent decimal numbers has many advantages in digital systems and, amongst these, the main advantage is the ease of conversion from and to decimals. However, there is a wastage of six (6) numbers from “A” to “F” as discussed above. In Binary Coded Decimal, each decimal digit is represented by a four (4) bit binary number (BCD), and each decimal digit can be represented by a weighted sum of binary values. It is known from previous articles, that the weight of a decimal digit, from right to left, increases by 10 times, whereas, of a binary digit (bit) by 2 times. In four-bit BCD, the first, second, third, and fourth digit has a weight of 20 = 1, 21 = 2, 22 = 4, and 23 = 8, respectively. In the following table, the binary power or weight of each BCD bit is shown.
Using the above table, the weighted sum of bits of “0000” to “1001” binary numbers equalizes to “0” to “9” decimal numbers, respectively. Starting from the right, the four bits of BCD give a weight of 8, 4, 2, and 1, respectively. The weights (8, 4, 2, and 1) of a BCD sum up to constitute a decimal number. Due to this reason, a BCD is also called an 8421 code as it represents a relevant decimal number in a 4-bit format.
The conversion of a decimal number, consisting of multiple decimal digits, requires obtaining an equivalent BCD for each decimal digit. For example, consider a decimal number of 91510, having three decimal digits i.e. “9”, “1”, and “5”. These decimal digits “9”, “1”, and “5” have equivalent binary coded decimals “1001”, “0001”, and “0101”, respectively. The combination of these binary coded decimals is the equivalent of 91510 in BCD as given below.
The following table lists each decimal number against their respective binary coded decimal (BCD). The BCD or 8421 code is unique for “0” to “9” digits and for numbers greater than “9” such as “10”, “11”, and “12” etc. each decimal digit is given the respective unique 8421 code, separately. For example, the “10” would make up an 8421 code of “0001 0000” where “0001” and “0000” are unique 8421 codes of “1” and “0”, respectively.
Decimal to BCD Conversion
There are multiple methods to obtain the BCD or 8421 code of a decimal number. Each method requires the processing of each decimal digit, separately, not the whole decimal number. First, and the easiest, way is to memorize these ten (10) BCD codes or lookup the BCD truth table for each decimal digit and find the respective BCD/ 8421 code. The second method would require the application of decimal to binary conversion on each (single) decimal digit i.e. repeated-division-by-2. The third method is to split each decimal digit into weights of bits summing up to desired decimal digit. The weighted binary digits form the equivalent BCD/ 8421 code. A few examples of decimal to equivalent BCD conversions are given below.
Decimal to BCD Conversion Examples
The decimal numbers: 6310, 86910, and 472810 are converted into their equivalent BCD numbers by use of the above-given BCD truth table.
BCD to Decimal Conversion
As each decimal digit is represented by a 4-bit BCD and, therefore, it is necessary to split the given binary number into groups of 4-bits. The 4-bit groups are formed from the least significant side (rightmost) to the most significant side (leftmost). Eventually, leading to the formation of the last 4-bit group which may require additional significant zero(s) to complete the 4-bit group. Each 4-bit group represents the respective BCD or 8421 code of that decimal digit. Using the above BCD truth table, equivalent decimal digits against respective BCD/ 8421 codes are obtained. The combination of decimal digits ultimately gives the representation of the desired decimal number. In the following examples, the BCD to decimal conversion is carried out to explain the conversion process.
BCD to Decimal Conversion Examples
The binary numbers: 10002, 100112, and 100101100101012 are converted into their equivalent decimal numbers by splitting into 4-bit groups of 8421 (BCD) codes and then finding equivalent decimal numbers against respective 8421 (BCD) codes using the above given BCD truth table.
The Binary Coded Decimal is a mere representation of a single decimal digit and a decimal number represented by BCD encoding is not the actual binary equivalent of that decimal number. For example, the BCD equivalent of 6310 is 011000112, whereas, the pure binary equivalent of 6310 is 001111112. The BCD representation of decimals is useful for displaying decimal values etc. but is not an efficient way of storing data and for performing arithmetic operations. The storage using BCD encoding would require an additional bit(s) compared to its equivalent true binary number. It is because of discarding six (6) binary numbers out of sixteen (16) as described above. For example, the representation of a three-digit decimal number requires 12-bits in BCD and, contrary to this, a 10-bit binary number can accommodate a decimal number up to “1024”. Moreover, BCD encoded binary numbers are not suitable for arithmetic operations. Consider a simple example of the addition of two BCD binary numbers which generates a carry bit, the addition of this carry bit to a BCD number of “1001” or “9” would lead to an invalid BCD code of “1010”. The solution requires conversion from binary to decimal i.e. 1010 and then reverting to BCD equivalent i.e. “0001 0000”. However, it is more suitable and convenient to convert BCD encoded numbers to pure binary numbers before performing any arithmetic operations.
Binary Coded Decimal Decoder IC
The usage of Binary Coded Decimal is useful in applications requiring the display of information in decimals. The digital or electronic systems display this information on LCD or 7-segment LED displays. In order to display decimal numbers, the binary numbers are converted to equivalent BCD numbers and a BCD decoder IC is used to display the decimal numbers on these displays. The widely used 7-segment display uses a BCD to 7-segment decoder IC to display BCD numbers. The 7-segment displays come in two variants depending on the configuration of LEDs with the supply voltage i.e. common anode, and common cathode. The common anode variant of the 7-segment requires a logic “LOW” at one of its segment’s inputs to turn it “ON”. Whereas, the common cathode 7-segment requires a logic “HIGH” to lit a segment. The commercially available BCD to 7-segment decoder ICs are 74LS47 and 74LS48. The 74LS47 produces an active-low output and, as such, is suitable for a common anode 7-segment display. On the other hand, a common cathode 7-segment display requires an active-high output BCD to 7-segment decoder IC i.e. 74LS48. In the following figure, a 74LS48 (active-high output) decoder IC with the common cathode 7-segment display is shown.
- The Binary Coded Decimal (BCD) is a 4-bit binary code meant to represent a decimal number. The Binary Coded Decimal has ten (10) unique binary codes each to represent a decimal number from “0” to “9”.
- The Binary Coded Decimal is also known as 8421 code where 8, 4, 2, and 1 represent the weight of the 4th, 3rd, 2nd, and 1st bit, respectively.
- The Binary Coded Decimal is similar to the Hexadecimal numbers but uses only “0” to “9” numbers and the rest of the numbers from “A” to “F” are wasted. Due to this, the storage of information in BCD format is not efficient and requires an additional bit(s) compared to pure binary equivalent.
- The conversion from decimal to BCD requires obtaining equivalent BCD/ 8421 code from the truth table. Whereas, conversion from BCD to decimal is the exact opposite of the decimal to BCD conversion process. However, this requires splitting the binary (BCD) number into 4-bit groups and may require additional significant zero(s) in the last (leftmost) group.
- It is appropriate to convert BCD numbers to pure binary numbers before performing any arithmetic operation.
- The BCD encoding is useful for displaying information in the form of decimal numbers and, as such, is widely used in 7-segment displays. The BCD to 7-segment decoder i.e. 74LS47, 74LS48, etc. is used to display decimal numbers on 7-segment displays.