BCD to Binary Converter – Free

This BCD to binary converter decodes binary-coded decimal digits and outputs the same number as an ordinary binary integer. It runs entirely in your browser.

How to use the BCD to Binary tool

  1. Enter the BCD nibbles in the BCD groups box, four bits per decimal digit. Example loads 0100 0101.
  2. Select Convert to rewrite the number.
  3. Read the pure binary integer in the Result box. The example, decimal 45, gives 101101.
  4. Select Copy to copy the integer, or Clear to enter new groups.

BCD and binary are different encodings

Binary-coded decimal stores a number digit by digit. Each decimal digit gets its own four bits, using the ordinary weights 8, 4, 2 and 1. The number 45 is 0100 for the 4 and 0101 for the 5. Pure binary stores the value as a whole, as a sum of powers of two, so 45 is 101101.

The two forms look alike but are not interchangeable. If you misread the BCD pattern 0100 0101 as a plain binary byte you get 69, not 45. This tool performs the proper conversion from one to the other.

How the BCD to binary conversion is done

The converter strips spaces, splits the input into 4-bit groups and reads each group as a digit from 0 to 9. The digits are joined into a decimal number, and that number is rewritten in base 2 with arbitrary-precision arithmetic. The result has no leading zeros and no fixed width.

Hardware usually takes another path. A shift-and-subtract circuit, the reverse of the double dabble algorithm, shifts the BCD value right one bit at a time and subtracts 3 from any nibble that is 8 or more. Both methods yield the same bits.

Worked example: 256 in BCD

The groups 0010 0101 0110 are the digits 2, 5 and 6. The number 256 is two to the eighth power, so its binary form is a 1 followed by eight zeros. Twelve bits of BCD become nine bits of binary, which shows why BCD is the less compact encoding.

0010 0101 0110  ->  digits 2 5 6  ->  256  ->  100000000

Input rules and error messages

The BCD groups box accepts up to 65,536 binary digits. Spaces and line breaks between groups are optional, and a 0b prefix is ignored.

  • The total number of bits must be a multiple of four. Otherwise you see Enter complete groups of four bits.
  • Each group must be 0000 through 1001. The six patterns from 1010 to 1111 return Invalid digit group, followed by the pattern.
  • Anything other than 0, 1 and whitespace returns Enter between 1 and 65,536 binary digits.
  • Sign nibbles are not supported. Packed decimal fields that end in 1100 or 1101 must have the sign removed first.
  • Leading zero digits are dropped in the result, so 0000 0000 0111 gives 111.

Where BCD shows up in real systems

Real-time clock chips such as the DS3231 keep seconds, minutes and hours in BCD registers, and firmware must convert them to binary before doing arithmetic. Mainframe packed decimal fields and some payment message formats also store amounts as BCD, so that each decimal digit is kept exactly as written.

Frequently asked questions

What is the difference between BCD and binary?

BCD encodes each decimal digit separately in four bits, while binary encodes the whole value in base 2. The number 99 is 1001 1001 in BCD and 1100011 in binary.

Why is 1010 an invalid BCD group?

A BCD group stands for one decimal digit, and digits stop at 9, which is 1001. The patterns 1010 through 1111 would mean 10 through 15, so they have no meaning in standard 8421 BCD.

Do I need spaces between the nibbles?

No. Whitespace is removed before parsing, so 01000101 and 0100 0101 are the same input. The only requirement is that the total bit count divides evenly by four.

How do I convert BCD 0001 0000 0000 to binary?

Those groups are the digits 1, 0 and 0, which is one hundred. One hundred in binary is 1100100, and that is what the tool returns.

Can it handle very long BCD numbers?

Yes. Up to 65,536 bits, or 16,384 decimal digits, are accepted. The conversion uses big integers, so the binary result is exact however long the number is.

What if I only want the decimal digits?

Use the BCD to Decimal tool. It decodes the same groups but stops at the digit string, keeping leading zeros, without converting the value to base 2.

Related tools