# Decimal-to-bcd-converter

A Decimal-to-BCD Converter is a tool that converts decimal numbers to binary-coded decimal (BCD) format. BCD is a binary representation of decimal numbers where each decimal digit is represented by a group of four bits.

Here’s how you can convert a decimal number to BCD:

1. Write the decimal number in binary format.
2. If the number of bits is less than 8, add leading zeros to make it 8 bits.
3. Group the binary digits into groups of 4, starting from the rightmost digit.
4. Convert each group of 4 binary digits to its equivalent BCD representation by converting the binary to decimal.
5. Write down the BCD representation of each group, and concatenate the BCD digits together to get the final BCD representation of the decimal number.

For example, let’s convert the decimal number 45 to BCD:

1. The binary representation of 45 is 00101101.
2. Add leading zeros to make it 8 bits: 00000000 00101101.
3. Group the binary digits into groups of 4: 0000 0000 0010 1101.
4. Convert each group of 4 binary digits to its equivalent BCD representation:
• 0000 -> 0
• 0000 -> 0
• 0010 -> 2
• 1101 -> 13
5. Write down the BCD representation of each group: 0000 0000 0010 1101, and concatenate the BCD digits together to get the final BCD representation of the decimal number: 0000000000101101.

Therefore, the BCD representation of the decimal number 45 is 0000000000101101.