Decimal to BCD Converter

Enter a decimal number to convert it to binary-coded decimal.

Result

0010 0000 0010 0101
0010000000100101
16

How it is calculated

The tool treats the input as a string of decimal digits and encodes each digit on its own as a 4-bit binary number: 0 = 0000, 1 = 0001, up to 9 = 1001. This is 8421 BCD, where the bits of each group are worth 8, 4, 2 and 1. It gives three results: the groups separated by spaces, the same bits joined together as one packed string, and the total bit count, bits = 4 × number of digits. Leading zeros are removed first, so 0007 is read as 7, and the value 0 becomes the single group 0000. Only the digits 0 to 9 are accepted; a minus sign, decimal point, comma, space or letter returns no result. Because each digit takes a full 4 bits, BCD is longer than ordinary binary for the same number.

Worked example

Convert 2025. Take each digit separately: 2 = 0010, 0 = 0000, 2 = 0010, 5 = 0101. Joined with spaces this is 0010 0000 0010 0101, and as a packed string 0010000000100101. Four digits at 4 bits each give a count of 16 bits. Plain binary would write 2025 as 11111101001, only 11 bits, but that form has no digit boundaries. In BCD the groups line up with the decimal digits, so 0010 is clearly the 2 in the thousands place.

Try this example →

Common mistakes

  • Confusing BCD with the binary form of the whole number. BCD of 47 is 0100 0111, whereas binary 47 is 101111; the two are not interchangeable in a circuit or register.
  • Typing a number with a decimal point, thousands separator, space or minus sign, such as 12.5 or 1,234. Each of these returns no result; enter only digits, and handle the sign or fraction separately.
  • Expecting leading zeros to be kept. Typing 0007 gives only 0111, so pad the output yourself if a register needs a fixed number of digits.
  • Reading the packed string as a binary number. 0010000000100101 is not the binary value of 2025; it only holds the digits 2, 0, 2, 5 in nibbles.
  • Assuming every 4-bit group is valid. BCD uses only 0000 to 1001; the patterns 1010 to 1111 never appear in the output and are invalid if you see them in BCD data.

About this calculator

Binary-coded decimal (BCD) is a way of encoding a decimal number where each individual digit — not the number as a whole — is converted separately into its own 4-bit binary nibble. This converter takes a decimal number, splits it into digits, and encodes each one (0-9 maps to 0000-1001), so for example the decimal 47 becomes 0100 0111 in BCD rather than 101111 as it would in pure binary.

Because BCD keeps each decimal digit separately addressable, it avoids the rounding and conversion overhead of binary-decimal translation, which is why digital electronics designers building seven-segment displays and calculators, and embedded-systems engineers working with older financial and industrial hardware still use it — many digital clocks, calculators, and legacy point-of-sale systems process values internally in BCD specifically because it maps cleanly onto decimal display digits.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    A handy sanity check: read the packed bits as hexadecimal. Because every nibble holds one digit from 0 to 9, 259 comes out as 0010 0101 1001, which is hex 259, and the digits simply carry over. If you need whole bytes for a register, a three-digit number has an odd count, so add a leading 0000 nibble yourself to get 0000 0010 0101 1001. What target are you encoding for: a display driver, an RTC chip or something else?

Popular calculators

All Calculators