## What is code conversion?

The method or technique used to convert code from one format to another is termed code conversion. Code conversions are most commonly used in computers, digital electronics, microprocessors, etc.

## What is code?

In digital electronics, a group of symbols is used to represent a letter or word, it can be said that letter is being encoded. The group of a symbol used to represent certain letters is known as code. Digitally, data is generated, stored, and transmitted with the help of bits. Combined circuits containing Logic gates. These circuits operate at binary values. Combined circuit results depend on the combination of current inputs.

### Bits

The smallest unit of data is termed bits. The bits are used to represent a logical state that consists of one or two values. To represent any data in the computer, the values are either 0 or 1.

### Binary code

The group of bits is termed binary codes. Computer programming uses binary language to calculate or represent all the data. Binary code represents any information in terms of 0 or 1. Binary code can be classified into two forms.

- Weighted code
- Non-weighted code

When binary code weights each digit they are termed as weighted code whereas when a digit does not have weights it is termed as non-weighted code.

## Types of code conversion

In digital electronics, several code conversion techniques are listed below.

- Binary to BCD conversion code
- BCD to binary conversion code
- BCD to excess-3 conversion code
- Excess-3 to BCD conversion code

## What is BCD?

BCD stands for binary coded decimal. The type of number system which uses binary numbers to represent a decimal number. With the help of BCD code, a decimal number is represented by a four-digit binary digit. BCD uses 0000-1001 binary numbers which are equivalent to 0-9 decimal numbers. Assume 1 digit decimal number, then its equivalent BCD will have 4 binary digits. Similarly, if a decimal number has 2 digits, then its equivalent BCD will have 8 binary digits. The list is given below shows binary and BCD code for decimal numbers 0-15.

Decimal Number | Binary Number | BCD |

0 | 0000 | 0000 |

1 | 0001 | 0001 |

2 | 0010 | 0010 |

3 | 0011 | 0011 |

4 | 0100 | 0100 |

5 | 0101 | 0101 |

6 | 0110 | 0110 |

7 | 0111 | 0111 |

8 | 1000 | 1000 |

9 | 1001 | 1001 |

10 | 1010 | 0001 0000 |

11 | 1011 | 0001 0001 |

12 | 1100 | 0001 0010 |

13 | 1101 | 0001 0011 |

14 | 1110 | 0001 0100 |

15 | 1111 | 0001 0101 |

## What is Excess-3 code?

Excess-3 code can also be represented as XS-3 code. It is a non-weighted code used to represent a decimal number. The decimal number can be easily represented in excess-3 code by adding 3 in its respective binary number. The excess-3 code of some number is represented in the list given below.

Decimal Number | Binary Number | Excess-3 Code |

0 | 0000 | 0011 |

1 | 0001 | 0100 |

2 | 0010 | 0101 |

3 | 0011 | 0110 |

4 | 0100 | 0111 |

5 | 0101 | 1000 |

6 | 0110 | 1001 |

7 | 0111 | 1010 |

8 | 1000 | 1011 |

9 | 1001 | 1100 |

## Binary to BCD conversion

BCD is a decimal number with a binary code, where each digit of the decimal number is represented by its equivalent binary number, and other important decimal numbers are also represented by the same binary number.

For example, a binary number system has base 2 because it has only two numbers representing any number. Similarly, a decimal number system has a base of 10, as it has 10 numbers representing a number.

The following steps are followed to convert the binary number into BCD.

Step 1- Convert the given binary code into a decimal number.

Step 2- Convert a decimal number into BCD code.

## BCD to Binary conversion

BCD is a decimal number with a binary code, where each digit of a decimal number is denoted by its equal binary number. That is to say, the LSB decimal number is represented by its equal binary number and similarly, the other important pieces of a decimal number are also represented by their same binary numbers.

Following are the steps to convert BCD code to binary code.

Step 1- Convert the given BCD number to a decimal number.

Step 2- Convert decimal to binary number.

## BCD to Excess-3 code conversion

The process of converting BCD to Excess-3 is much simpler in some versions. The Excess-3 code can be calculated by adding 3, i.e., 0011 to each four-letter BCD code. Below is a true BCD conversion table into Excess-3 code. In the table below, the variables A, B, C, and D represent the pieces of binary numbers. The variable 'D' represents LSB, while the 'A' represents MSB. In the same way, the variables w, x, y, and z represent the pieces of code Excess-3. The variable 'z' represents LSB, and the variable 'w' represents MSB. ‘Indifference situations’ are expressed in the ‘X’ variable.

Follow the steps given below to find the excess-3 code of the given BCD number.

Step 1- Convert the given BCD number to its decimal equivalent.

Step 2- Add ${\left(3\right)}_{10}$ to the decimal number.

Step 3- Convert decimal to its equivalent binary to obtain excess-3 code.

## Excess-3 code to BCD code conversion

Note the step to convert excess-3 code to its equivalent BCD code.

Step: Subtract ${\left(0011\right)}_{2}$ to the given excess-3 code to obtain its equivalent BCD.

## Common Mistakes

- Following are the code with their base number.

Binary – 2

Excess-3 – XS-3

Decimal- 10

Octal – 8

Hexadecimal – 16

- While converting a decimal number to their binary equivalent, the decimal number is divided by 2 whereas converting binary to decimal number gets multiplied by 2.

## Context and Applications

In each of the expert exams for undergraduate and graduate publications, this topic is huge and is mainly used for:

- Bachelor of technology in the electrical and electronic department
- Bachelor of Science in physics
- Master of Science in physics

## Related Concepts

- Number system
- Base conversions

## Practice Problems

**Q1**. Gray code are used_____.

Shaft encoders

Shaft encoders

Both

None of these

**Correct option:** (a)

**Explanation:** Gray codes are used in shaft encoders because the code of successive numbers differs exactly by one bit from its precede.

**Q2** Excess-3 is extensively used for_____.

- Addition
- Subtraction
- Multiplication
- Divide

**Correct answer:** (b)

**Explanation:** Excess-3 is extensively used for subtraction because every code in XS-3 has its complement. 1’s complement of the code yields 9’s complement of a number itself.

**Q3.** ECC codes are used for checking the information on the disk.

MBR disks

RAID disks

Both

None of these

**Correct option:** (b)

**Explanation:** In RAID disks, ECC codes are used for checking the information on the disk at the time of reading and writing the information, and if it's a mismatch with the information then the correction is made on the fly.

**Q4. **Binary coded decimal is a combination of____________.

(a) two binary digits

(b) three binary digits

(c) four binary digits

(d) five binary digits

**Correct answer:** (c)

**Explanation: **Binary coded decimal is a combination of 4 binary digits. For example-8421.

**Q5. **Code is a symbolic representation of __________ information.

(a) continuous

(b) discrete

(c) analog

(d) none of these

**Correct answer:** (b)

**Explanation:** A code is a symbolic representation of different information, which may be present in numbers, letters, or the plural. In particular, it is represented using a numerical system such as decimal or binary and the like.

### Want more help with your electrical engineering homework?

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.

### Search. Solve. Succeed!

Study smarter access to millions of step-by step textbook solutions, our Q&A library, and AI powered Math Solver. Plus, you get 30 questions to ask an expert each month.

### Digital Electronics

### Number System

### Arithmetic Operation and Code Conversion in Number System

### Search. Solve. Succeed!

Study smarter access to millions of step-by step textbook solutions, our Q&A library, and AI powered Math Solver. Plus, you get 30 questions to ask an expert each month.