Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

BCD to binary converter: two digits, live

A BCD to binary converter turns two decimal digits, a tens digit T and a units digit U in BCD, into one 7-bit binary number B = 10T + U, from 0 to 99. Because 10T = 8T + 2T, the circuit only needs shifts and adders: two rows of full adders compute 8T + 2T and then add U.

Multiplying by 10 in binary is cheap because 10 = 8 + 2: 8T is T shifted left three places and 2T is T shifted left one place, so they cost only wiring. The first row of full adders adds those two shifted copies of the tens digit, and the second row adds the units digit. The lowest bit needs no adder at all, because 8T and 2T are both even: B0 is simply U0. Only the 100 codes with both digits from 0 to 9 are valid BCD, and all of them are checked on the live circuit. The reverse direction is the binary to BCD converter, and the BCD converter tool converts any number either way with the steps shown. The adders are the verified full adder, saved as a part.

Big circuit: pinch, scroll or tap + to zoom in, then drag to move around.

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 →

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “BCD to binary converter”, https://digiwleea.wleeaf.dev/tools/build/bcd-to-binary/

What you need

Step by step

  1. Place the tens digit T3 to T0, the units digit U3 to U0, and probes B6 to B0.
  2. Wire T shifted one place (2T) and three places (8T) into a row of full adders: bit k adds T(k-1) and T(k-3).
  3. Add the units digit U to that sum with a second row of full adders.
  4. Wire U0 straight to B0.
  5. Set T = 4 and U = 2: B reads 0101010, which is 42.

BCD to binary: example rows

DecimalT and U (BCD)8T + 2T + UB6..B0
00000 00000 + 0 + 00000000
70000 01110 + 0 + 70000111
90000 10010 + 0 + 90001001
100001 00008 + 2 + 00001010
250010 010116 + 4 + 50011001
420100 001032 + 8 + 20101010
630110 001148 + 12 + 30111111
640110 010048 + 12 + 41000000
991001 100172 + 18 + 91100011

Before the page is built, all 100 valid inputs, 00 to 99, are checked on the live circuit against 10T + U.

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.

More builds: Selecting, routing and decoding

All 246 build guides, by topic

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 BCD to binary converter in the lab →

Frequently asked

How do you convert BCD to binary?

Multiply the tens digit by 10 and add the units digit: B = 10T + U. In hardware 10T is 8T + 2T, two shifted copies of T, so the converter is just two rows of adders.

How many bits does a 2-digit BCD to binary converter need?

Seven output bits, because the largest value, 99, is 1100011 in binary. The input is eight bits, four per BCD digit.

Why is the lowest bit of the result just U0?

Because 8T and 2T are both even, adding them never changes bit 0. So bit 0 of 10T + U is bit 0 of U.