0% found this document useful (0 votes)
36 views7 pages

Codes 1

The document provides an overview of Binary Coded Decimal (BCD) and its variants, including the 8421, 4221, and 5421 codes, explaining how to convert between BCD and binary formats. It also introduces the Excess-3 code, which simplifies arithmetic operations by adding 3 to each decimal digit before converting to binary. Examples illustrate the conversion processes for both BCD-to-binary and binary-to-BCD, as well as the calculation of Excess-3 codes.

Uploaded by

Joshua Obenza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views7 pages

Codes 1

The document provides an overview of Binary Coded Decimal (BCD) and its variants, including the 8421, 4221, and 5421 codes, explaining how to convert between BCD and binary formats. It also introduces the Excess-3 code, which simplifies arithmetic operations by adding 3 to each decimal digit before converting to binary. Examples illustrate the conversion processes for both BCD-to-binary and binary-to-BCD, as well as the calculation of Excess-3 codes.

Uploaded by

Joshua Obenza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

AST 122

(DIGITAL ELECTRONICS)
2nd Semester AY 2024-2025

By: Maricar H. Nudalo, MSIT


Part-time Instructor
2.0 BINARY CODES
2.1 Binary coded decimal

Binary Coded Decimal (BCD) - is a type of binary code used to represent a given decimal number in an equivalent binary
form.

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.

Example: the BCD equivalent of (23.15)10 10 is written as (0010 0011.0001 0101)𝐵𝐶𝐷.

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 weight.

Other weighted BCD codes include the 4221 BCD and 5421 BCD codes. Again, 4, 2, 2 and 1 in the 4221 BCD code and 5, 4,
2 and 1 in the 5421 BCD code represent weights of the relevant bits.

Table 2.1 shows a comparison of 8421, 4221 and 5421 BCD codes. As an example, (98.16)10 will be written as 1111
1110.0001 1100 in 4221 BCD code and 1100 1011.0001 1001 in 5421 BCD code. Since the 8421 code is the most popular of
all the BCD codes, it is simply referred to as the BCD code
Table 2.1 BCD Codes

Decimal 8421 BCD code 4221 BCD code 5421 BCD code
0 0000 0000 0000
1 0001 0001 0001
2 0010 0010 0010
3 0011 0011 0011
4 0100 1000 0100
5 0101 0111 1000
6 0110 1100 1001
7 0111 1101 1010
8 1000 1110 1011
9 1001 1111 1100
2.1.1 BCD-to-Binary Conversion
A given BCD number can be converted into an equivalent binary number by first writing its decimal equivalent and
then converting it into its binary equivalent. As an example, we will find the binary equivalent of the BCD number
0010 1001.0111 0101:

• BCD number: 0010 1001.0111 0101.


• Corresponding decimal number: 29.75.
• The binary equivalent of 29.75 can be determined to be 11101 for the integer part and .11 for the fractional part.
• Therefore, (0010 1001.0111 0101)𝐵𝐶𝐷 = (11101.11)2

We will find the binary equivalent of (29.75)10 .


Solution
• The integer part = 29

Divisor Dividend Remainder


2 29 —
2 14 1
2 7 0 The remainders written in
2 3 1 reverse order constitute
2 1 1 the binary equivalent
— 0 1
• The binary equivalent of (29)10 is therefore (11101)2
• The fractional part = .75 the integral part of
• 0.75 × 2 = 1.5, integral part:1 resultant decimal number
• 0.5 × 2 = 1, integral part:1 will be first digit of fraction
• The binary equivalent of (0.75)10 = (.11)2 binary number
• Therefore, the binary equivalent of (29.75)10 = (11101.11)2
2.1.2 Binary-to-BCD Conversion

The process of binary-to-BCD conversion is the same as the process of BCD-to-binary conversion executed in reverse order.
A given binary number can be converted into an equivalent BCD number by first determining its decimal equivalent and then
writing the corresponding BCD equivalent. As an example, we will find the BCD equivalent of the binary number
10101011.101:
10101011 = (1×27 ) + (0×26 ) + (1×25 ) + (0×24 ) + (1×23 ) + (0×22 )+ (1×21 ) + (1×20 )
= 128 + 0 + 32 + 0 + 8 + 0 + 2 + 1
= 171
0 .101 = (1×2−1 )+ (0×2−2 )+ (1×2−3 )
= (1 × ½) + (0 × ¼) + (1 × 𝟏 𝟖)
= 0.5 + 0 + 0.025
= 0.625

Note: if it is negative make it positive by inverting the bits and adding one.

• The decimal equivalent of this binary number can be determined to be 171.625.


• The BCD equivalent can then be written as 0001 0111 0001.0110 0010 0101.
2.2 Excess-3 Code
The excess-3 code is another important BCD code. It is particularly significant for arithmetic operations as it
overcomes the shortcomings encountered while using the 8421 BCD code to add two decimal digits whose sum exceeds
9. The excess-3 code has no such limitation, and it considerably simplifies arithmetic operations. The excess-3 code for a
given decimal number is determined by adding ‘3’ to each decimal digit in the given number and then replacing each digit
of the newly found decimal number by its four-bit binary equivalent.

Table 2.2 Excess-3 code equivalent of decimal numbers.


Decimal number Excess-3 code
0 0011
1 0100
2 0101
3 0110
4 0111
5 1000
6 1001
7 1010
8 1011
9 1100
If the addition of ‘3’ to a digit produces a carry, as is the case with the digits 7, 8 and 9, that
carry should not be taken forward. The result of addition should be taken as a single entity and
subsequently replaced with its excess-3 code equivalent.

Example: let us find the excess-3 code for the decimal number 597:

• The addition of ‘3’ to each digit yields the three new digits/numbers ‘8’,
‘12’ and ‘10’.
• The corresponding four-bit binary equivalents are 1000, 1100 and 1010
respectively.
• The excess-3 code for 597 is therefore given by:
1000 1100 1010 = 100011001010

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy