- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
BCD to Excess-3 Conversion
Let’s start this tutorial with a basic overview of BCD (Binary Coded Decimal) and Excess-3 codes. Thereafter, we will proceed further to discuss BCD to Excess 3 conversion.
What is BCD?
BCD stands for Binary Coded Decimal. BCD is a coding scheme used to represent decimal numbers in the binary format. In BCD coding scheme, each decimal digit, from 0 to 9, is encoded as a group of 4-bits. The BCD codes for 0 to 9 in the decimal number system is given in the table below.
Decimal Digit |
Binary Coded Decimal (BCD) |
---|---|
0 |
0000 |
1 |
0001 |
2 |
0010 |
3 |
0011 |
4 |
0100 |
5 |
0101 |
6 |
0110 |
7 |
0111 |
8 |
1000 |
9 |
1001 |
As we know, a 4-bit binary can represent total 16 digits, but in BCD, the codes from 10 to 15, i.e. 1010, 1011, 1100, 1101, 1110, 1111 are considered illegal codes.
Binary coded decimal (BCD) is a widely used coding scheme in digital system to perform different arithmetic operations. BCD provides easy conversion between binary and decimal systems. However, BCD requires more number of bits to represent a decimal number than the pure binary number.
For example, consider a decimal number 825, its BCD representation is 1000 0010 0101, and the pure binary representation is 1100111001. Hence, BCD takes 12 digits to represent 825, while pure binary requires only 10 digits. Although, the conversion between BCD and decimal is easier than conversion between pure binary and decimal.
What is Excess-3 Code?
Excess-3 code, also known as XS-3 code is a binary code used in a variety of digital electronic systems. Excess-3 code is a basically a self-complementing binary code. It is a non-weighted binary coded decimal (BCD) code. In the Excess-3 code, each decimal digit (from 0 to 9) is represented by an 8421BCD code plus 3 (0011). Being a sequential code, it can be used to perform arithmetic operations. However, the Excess-3 code has six invalid states, i.e. 0000, 0001, 0010, 1101, 1110, and 1111.
The following table shows the Excess-3 codes for the decimal digits from 0 to 9 −
Decimal Digit |
Excess-3 (XS-3) Code |
---|---|
0 |
0011 |
1 |
0100 |
2 |
0101 |
3 |
0110 |
4 |
0111 |
5 |
1000 |
6 |
1001 |
7 |
1010 |
8 |
1011 |
9 |
1100 |
The use of Excess-3 code simplifies the arithmetic operations. This code was commonly used in older electronic devices. In modern electronic systems, the use of Excess-3 code becomes less common.
After getting insights into the basics of BCD code and Excess-3 code individually, let us now discuss their conversion.
BCD to Excess-3 Conversion
BCD to Excess-3 conversion involves the transformation of a binary coded decimal (BCD) number into its corresponding Excess-3 number.
The conversion of BCD to Excess-3 code is performed as per the following steps −
Step 1 − Take the given BCD code.
Step 2 − Add 0011 (3) to each BCD code to obtain its equivalent Excess-3 code.
Step 3 − Combine the Excess-3 codes of each BCD code to obtain the complete Excess-3 code for the given BCD number.
Let us consider some solved numerical examples to understand the process of BCD to Excess-3 conversion.
Example 1
Convert the BCD number 627 (0110 0010 0111) into its equivalent Excess-3 code.
Solution −– Given BCD number is −
627 = 0110 0010 0111
Adding 3 (0011) to each BCD code to obtain its equivalent Excess-3 code as below,
6 + 3 = 0110 + 0011 = 1001 2 + 3 = 0010 + 0011 = 0101 7 + 3 = 0111 + 0011 = 1010
Combining all the Excess-3 codes together to obtain the final result,
(627)10 = (1001 0101 1010)XS-3
Hence, the BCD number (0110 0010 0111)BCD is equivalent to the Excess-3 code (1001 0101 1010)XS-3.
Example 2
Convert the BCD number 989 (1001 1000 1001)BCD into its equivalent Excess-3 code.
Solution − The given BCD number is,
989 = (1001 1000 1001)BCD
Adding 3 (0011) to each BCD code to obtain the equivalent Excess-3 code as below,
9 + 3 = 1001 + 0011 = 1100 8 + 3 = 1000 + 0011 = 1011 9 + 3 = 1001 + 0011 = 1100
Combining all the Excess-3 codes to obtain the final result as below.
(989)10 = (1001 1000 1001)BCD = (1100 1011 1100)XS-3
Hence, the BCD number (1001 1000 1001)BCD is equivalent to the Excess-3 code (1100 1011 1100)XS-3.
Excess-3 to BCD Code Conversion
Excess-3 to BCD code conversion involves the transformation of Excess-3 code into BCD (Binary Coded Decimal).
The conversion of the Excess-3 code into its equivalent binary coded decimal (BCD) is done as per the following steps −
Step 1 − Take each Excess-3 code.
Step 2 − Subtract 3 from each Excess-3 code. The result will be the equivalent BCD code.
Step 3 − Combine all the BCD codes equivalent to each Excess-3 code to obtain the final result in BCD representation.
Now, let us consider some numerical examples to understand the conversion of Excess-3 into BCD code.
Example 3
Convert the Excess-3 code (1010 1100 1001) into its equivalent BCD code.
Solution − The given Excess-3 code is
(1010 1100 1001)XS-3
Subtracting 3 (0011) from each Excess-3 code as below.
1010 – 0011 = 0111 1100 – 0011 = 1001 1001 – 0011 = 0110
Hence, the Excess-3 code (1010 1100 1001) is equivalent to the BCD code (0111 1001 0110).
Example 4
Convert the Excess-3 code (0011 0100 0101) into its equivalent BCD code.
Solution − The given Excess-3 code is
(0011 0100 0101)XS-3
Subtracting 3 (0011) from each Excess-3 code as below.
0011 – 0011 = 0000 0100 – 0011 = 0001 0101 – 0011 = 0010
Hence, the Excess-3 code (0011 0100 0101)XS-3 is equivalent to the BCD code (0000 0001 0010)BCD.
Conclusion
This is all about conversion of Binary Coded Decimal (BCD) into Excess-3 (XS-3) code. In this tutorial, we explained how you can convert BCD to Excess-3 codes and vice versa.