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

How to build a BCD to excess-3 code converter

A BCD to excess-3 converter adds 3 to a decimal digit written in BCD: 0 (0000) becomes 0011, 9 (1001) becomes 1100. With the six unused BCD codes treated as don't-cares, four short equations do it: E0 = NOT B0, E1 = B1 XNOR B0, E2 = B2 XOR (B1 OR B0) and E3 = B3 OR B2 (B1 OR B0).

Excess-3 (XS-3) writes each decimal digit as its value plus 3. Its best-known property is that it is self-complementing: inverting every bit of a digit gives the code of 9 minus that digit, which made decimal subtraction simpler in early calculators and computers. Because inputs 10 to 15 never occur in BCD, the K-maps can use them as don't-cares, which is why the converter needs only six gates rather than a full 4-bit adder. All ten valid digits are checked before the page is built; the reverse direction, B = E - 3, is the same idea with subtraction.

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 the BCD inputs B3 to B0 and probes E3 to E0.
  2. Bit 0 just flips: E0 = NOT B0 (adding 3, an odd number, always changes the last bit).
  3. Bit 1: E1 = B1 XNOR B0.
  4. Build B1 OR B0 once. Then E2 = B2 XOR (B1 OR B0) and E3 = B3 OR (B2 AND (B1 OR B0)).
  5. Count the inputs from 0000 to 1001 and check each output is the input plus 3.

BCD to excess-3 table

DecimalBCD B3..B0Excess-3 E3..E0
000000011
100010100
200100101
300110110
401000111
501011000
601101001
701111010
810001011
910011100

Read any row and its mirror: 2 is 0101 and 7 is 1010, the bitwise inverse, because 2 + 7 = 9. That self-complementing pattern holds for every pair of digits that add up to 9. Inputs 1010 to 1111 are not BCD digits, so the circuit's outputs for them do not matter.

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 BCD to excess-3 code converter in the lab →

Frequently asked

What is excess-3 code?

A decimal code that writes each digit as its 4-bit binary value plus 3, so 0 is 0011 and 9 is 1100. It is self-complementing: inverting all four bits gives the code for 9 minus the digit.

How do you convert BCD to excess-3?

Add 3 (0011) to the BCD digit. As logic, with codes 10 to 15 as don't-cares: E0 = NOT B0, E1 = B1 XNOR B0, E2 = B2 XOR (B1 OR B0), E3 = B3 OR B2 (B1 OR B0).

Why is excess-3 called self-complementing?

Because the 9's complement of a digit is just the bitwise NOT of its excess-3 code. For example 3 is 0110 and 6 is 1001. That made decimal subtraction easy to do with the same adder.

How do you convert excess-3 back to BCD?

Subtract 3 from each 4-bit group, or equivalently add 1101 and drop the carry. A gate-level converter uses the same K-map method with the six unused codes as don't-cares.