Binary to BCD Converter – Free

This binary to BCD converter reads an unsigned binary integer and writes its decimal digits as 4-bit groups, the 8421 form of binary-coded decimal.

How to use the Binary to BCD tool

  1. Enter the unsigned integer in the Binary box. Spaces between bit groups are allowed.
  2. Select Convert. The tool finds the decimal value and encodes each digit separately.
  3. Read the BCD groups in the Result box, one 4-bit group per decimal digit with the most significant digit first.
  4. Select Copy to take the groups, or Example to convert 101101.

What binary-coded decimal is

Pure binary encodes the whole number as one sum of powers of two. BCD encodes the number digit by digit: every decimal digit gets its own four bits with the weights 8, 4, 2 and 1. The digit 9 is 1001, and the six patterns from 1010 to 1111 are never used.

The cost is space. Four bits could hold sixteen values but BCD uses ten, so one byte holds 0 to 99 where pure binary holds 0 to 255. The benefit is that each digit can be sent to a display or printed without any division.

Worked example: binary to BCD for 101101

The input 101101 is 45 in decimal. The digit 4 is 0100 and the digit 5 is 0101, so the output is 0100 0101. Note that the six input bits became eight output bits and the patterns look unrelated. Only the value is the same.

At 1010 the difference becomes obvious. Ten needs two decimal digits, so its BCD form is 0001 0000, while values 0 to 9 are the same in both notations apart from padding to four bits.

101101  ->  0100 0101             (45)
1010  ->  0001 0000               (10)
11111111  ->  0010 0101 0101      (255)
10011010010  ->  0001 0010 0011 0100   (1234)

How the conversion is done

Hardware usually converts with the double dabble algorithm: shift the binary value left one bit at a time into a BCD register, and before each shift add 3 to any BCD digit that is 5 or more. It needs only shifts and small adders.

This tool reaches the same digits a simpler way. It parses the bits as an exact integer, writes that integer in decimal, and turns each decimal character into four bits. The output has no sign nibble and no padding digits, just one group per digit of the number.

Input limits and common uses

The value must be unsigned. A minus sign is not accepted, and neither is anything else besides 0, 1, whitespace and one leading 0b. Leading zeros in the input do not add BCD digits: 0000 1111 gives 0001 0101, the two digits of 15. Up to 65,536 bits can be converted.

BCD is common wherever digits matter more than arithmetic speed: seven-segment display drivers, real-time clock chips that keep seconds, minutes and hours in BCD registers, and packed decimal fields in financial records.

Frequently asked questions

How do I convert binary to BCD by hand?

Convert the binary number to decimal, then write each decimal digit as four bits. For 11111111 the decimal value is 255, and the digits 2, 5 and 5 become 0010 0101 0101.

Why is the BCD result longer than the binary input?

BCD spends four bits on every decimal digit, but a decimal digit only carries about 3.32 bits of information. The result is therefore roughly 20% longer than minimal binary, rounded up to whole 4-bit groups.

Is BCD the same as hexadecimal?

No, but they look alike. If you read BCD groups as hex digits you see the decimal digits: 0100 0101 is 0x45, which displays as 45. The numeric value of 0x45 is 69, not 45.

Can the tool convert negative numbers to BCD?

No. The input is read as an unsigned bit pattern and a minus sign is rejected. BCD formats that carry a sign use an extra nibble, and conventions for it differ between systems.

What is the difference between BCD and Excess-3?

Excess-3 adds three to each decimal digit before writing it in four bits, so 4 becomes 0111. Plain BCD writes the digit as is. The Binary Excess-3 Converter on this site produces that variant.

Related tools