Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksToolsOpen the lab →

How to build a 4-bit binary to BCD converter

A 4-bit binary to BCD converter turns a binary number from 0 to 15 into two decimal digits: a tens digit T0 = B3 AND (B2 OR B1), which is 1 for 10 and above, and a units digit that is the number itself up to 9 and the number minus 10 above that.

Displays and decimal readouts need one 4-bit BCD code per decimal digit, so 13 must become 0001 0011, not 1101. For four input bits the tens digit can only be 0 or 1, and the units digit comes straight from K-maps over the 16 rows. One bit is free: subtracting 10 never changes whether a number is odd, so U0 = B0. Feed the units digit into a BCD to 7-segment decoder to light a display. For wider numbers the usual method is the shift-and-add-3 (double dabble) algorithm, which builds the BCD digits one input bit at a time. All 16 inputs are checked before the page is built.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

What you need

Step by step

  1. Place inputs B3 (most significant) to B0, and probes for the tens bit T0 and the units digit U3 to U0.
  2. Tens: the number is 10 or more exactly when B3 is 1 and B2 or B1 is 1 (10 is 1010, 12 is 1100), so T0 = B3 AND (B2 OR B1).
  3. Units bit 0: wire B0 straight to U0.
  4. Units bits 1 to 3 from the K-maps: U1 = B3' B1 + B3 B2 B1', U2 = B3' B2 + B3 B2 B1, U3 = B3 B2' B1'.
  5. Count the inputs from 0000 to 1111 and read the outputs as two decimal digits: up to 9 the tens bit stays 0, then 10 shows as 1 and 0000.

Binary to BCD truth table

DecimalB3 B2 B1 B0Tens T0Units U3 U2 U1 U0
0000000000
1000100001
2001000010
3001100011
4010000100
5010100101
6011000110
7011100111
8100001000
9100101001
10101010000
11101110001
12110010010
13110110011
14111010100
15111110101

Rows 0 to 9 pass straight through with a tens digit of 0. From 10 to 15 the tens digit is 1 and the units digit is the input minus 10 (1010 becomes 0000, 1111 becomes 0101), so the units digit never goes above 5 in that half.

You can also read the full theory in the lesson on BCD. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.

Build more parts from gates

Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.

Open the binary to BCD converter in the lab →

Frequently asked

How do you convert binary to BCD?

For a 4-bit input, set the tens digit to 1 when the number is 10 or more and subtract 10 from the units digit in that case; as logic that is T0 = B3 (B2 + B1) plus a few gates per units bit. For wider inputs, the double dabble method shifts the binary number left one bit at a time into BCD digits and adds 3 to any digit that is 5 or more before each shift.

What is 13 in BCD?

0001 0011: the tens digit 1 and the units digit 3, each as its own 4-bit code. In plain binary 13 is 1101.

Why is the lowest units bit just B0?

Subtracting 10, an even number, never changes whether a number is odd or even, so the last bit of the units digit always equals the last bit of the input.

What is the difference between binary and BCD?

Binary writes the whole number in base 2, so 4 bits reach 15. BCD encodes each decimal digit separately in 4 bits, which wastes the codes 1010 to 1111 but makes decimal display and rounding simple.