BCD-Code Converter

required files are loaded...

This calculator can be used to convert decimal numbers to BCD code and BCD codes to decimal notation. BCD stands for "Binary Coded Decimal". When converting from a BCD code to a decimal number, no pseudotetrades are accepted.

Decimal to BCD code conversion

To determine the BCD code for a decimal number, each digit of the decimal number must be converted successively into a binary number consisting of 4 bits. For example, if there is a 5 in the decimal number, this 5 is converted to "0101". The resulting 4-bit blocks are called "nibble". The following table can be used for the conversion:

decimalbinary
00000
10001
20010
30011
40100
50101
60110
70111
81000
91001

Example coding:

As an example, the number 28913 is to be represented as a BCD code.

conversion from decimal system to bcd code

So the BCD code is: 0010 1000 1001 0001 0011

Convert BCD code to decimal

To convert a BCD code back to a decimal number, the number is divided into 4-bit blocks. Each 4-bit block is converted to the decimal system and the decimal digits obtained are concatenated.

Example decoding:

The BCD code from the example above is to be converted back to the decimal system.

conversion from bcd code to decimal

The result is therefore 28913.

Pseudotetrades

With 4 bits 16 digits can be represented. However, only 10 4-bit combinations are used to encode the decimal digits. The remaining 6 4-bit combinations are called pseudotetrades and do not represent any valid digit. However, they can be assigned a special meaning (for example, sign, comma or other characters).

Numbers with decimal point

There are different strategies to store numbers with a decimal point as BCD code. For example, pseudotetrades can be used for this. Another strategy can be that numbers are always coded with the same number of places before the decimal point and the same number of places after the decimal point (fixed point numbers). In this case, missing zeros may have to be added to the front and back.

Advantages and disadvantages

Many decimal numbers cannot be represented exactly in the IEEE-754 floating point format, although they are actually very compact in decimal representation. For example, 7.1 cannot be represented exactly. However, 7.1 can be converted into a BCD code without rounding. However, calculations with BCD codes are more complex and therefore slower than with floating point numbers and the memory is used more inefficiently due to the pseudotetrades.

good explanatory videos on Youtube

Share:FacebookTwitter