Related Concepts: 2.01 BCD & Weighted Digital Codes | 2.03 Gray Code & Code Conversions | 2.04 Error Control, Parity Generators & Checkers
2.02 Excess-3 Code & Self-Complementing Logic
What is a Self-Complementing Code?
A 4-bit binary code is defined as Self-Complementing if the 1’s complement {bitwise inversion: } of any decimal digit’s code word yields the exact code word of its 9’s decimal complement ().
graph LR subgraph Self-Complementing Symmetry D2[Decimal Digit 2: 0101] -->|Bitwise Inversion| InvD2[1's Comp: 1010] InvD2 -->|Equals| D7[Decimal Digit 7 = 9 - 2: 1010] end
1. What is Excess-3 Code?
Concept: Excess-3 Definition
Excess-3 (XS-3) is a non-weighted binary code. Each decimal digit (0 through 9) is represented by the 4-bit binary value of .
- Decimal:
- Excess-3 representation:
1.1 Differences: Standard BCD (8421) vs. Excess-3 (XS-3)
| Feature | Standard BCD (8421) | Excess-3 (XS-3) |
|---|---|---|
| Weighting | Weighted positional code (weights: ). | Non-weighted code (each representation is ). |
| Self-Complementing | No (e.g. 1’s complement of BCD 1 [0001] is 1110, which is invalid, not BCD 8). | Yes (bitwise inversion of XS-3 yields XS-3 ). |
| Zero Representation | 0000 (equal to electrical zero/disconnected state). | 0011 (prevents false line fault detection). |
| Arithmetic Carry Rule | Add 0110 () if sum or carry is generated. | Add 0011 () if carry is generated; subtract 0011 () if no carry is generated. |
| Unused States | States 1010 to 1111 () are invalid. | States 0000 to 0010 () and 1101 to 1111 () are invalid. |
Why do we use Excess-3?
- Simplified Subtraction (Self-Complementing): The primary advantage of Excess-3 is that the 1’s complement of an Excess-3 digit is the Excess-3 representation of its 9’s complement (e.g. 1’s complement of
0100[1] is1011[8]). This makes subtraction circuits in early decimal calculators incredibly simple to design. - Transmission Reliability: Unlike standard BCD where is represented by
0000(which is indistinguishable from a line disconnection or fault), the smallest valid Excess-3 code word is0011(decimal 0). This prevents signal transmission line faults from being misread as valid data.
2. Excess-3 Addition Mechanics
Because Excess-3 values always have an extra offset of built-in, adding two Excess-3 digits yields:
To restore the correct Excess-3 bias of :
- Case A: A carry is generated (Sum ) Add
0011() to correct the sum nibble. - Case B: No carry is generated (Sum ) Subtract
0011() (or add1101) to correct the sum nibble.
Step-by-Step Addition Examples:
Example 1: Excess-3 Addition with Sum (No Carry)
Add and in Excess-3:
0101 & (2 + 3 = 5) \\ +0110 & (3 + 3 = 6) \\ \hline 1011 & (\text{Raw Binary Sum} = 11_{10} \to \text{No Carry}) \\ -0011 & (\text{No Carry} \implies \text{Subtract } 3) \\ \hline \mathbf{1000} & (\text{Corrected Sum} = 8_{10} \implies 5_{\text{decimal}} \text{ in XS-3}) \end{array}$$ **Final Answer:** **$1000_{\text{XS-3}}$** (corresponds to $5_{10}$).
Example 2: Excess-3 Addition with Sum (Carry Generated)
Add and in Excess-3:
1001 & (6 + 3 = 9) \\ +1000 & (5 + 3 = 8) \\ \hline \mathbf{1} \ 0001 & (\text{Raw Binary Sum} \to \text{Carry generated!}) \\ +0011 & (\text{Carry generated} \implies \text{Add } 3 \text{ to sum nibble}) \\ \hline \mathbf{1} \ 0100 & (\text{Carry is pushed to next nibble}) \end{array}$$ Grouped into 4-bit nibbles: $\mathbf{0100\ 0100_{\text{XS-3}}}$ (corresponds to $11_{10}$ in decimal).
3. Mathematical Proof: Excess-3 is a Self-Complementing Code
Major Exam Proof (PYQ 2021, 2023, 2025 — 8 to 10 marks)
Question (verbatim): What is self-complementary code? “Excess-3 code is a self-complementary code” — justify the statement.
Answer both halves: the definition (§ top of this note) earns the first few marks, the algebraic justification below earns the rest. A truth-table demonstration alone is usually marked down — the examiner’s word “justify” is asking for the general proof.
Step-by-Step Proof:
-
Definition of Excess-3 Code: The Excess-3 code word for any decimal digit () is constructed by adding to its standard 4-bit binary equivalent:
-
Evaluating the 9’s Complement of (): The Excess-3 code word for the 9’s complement of is:
-
Evaluating the 1’s Complement of : Taking the bitwise 1’s complement of a 4-bit number is mathematically equivalent to subtracting it from (): Substituting :
-
Comparing Results:
4. The Mathematics of Self-Complementing Weighted Codes
Unlike Excess-3 (which is non-weighted), many weighted 4-bit codes (like , ) are also self-complementing. There is a strict mathematical constraint on the weights of such codes.
The Self-Complementing Weight Theorem
For a weighted 4-bit binary code with weights to be self-complementing, the sum of its individual weights must equal exactly 9:
Algebraic Proof:
- Let the code representation of a decimal digit be . Its value is:
- For the code to be self-complementing, the 9’s complement () must be represented by the bitwise inverted word :
- Add the two equations together:
- Since (as one bit is always
0and the other is1):
Verification of Common Codes:
- Code: Self-complementing.
- Code: Self-complementing.
- BCD Code: Not self-complementing.
5. Complete 9’s Complement Symmetry Table
| Decimal Digit () | BCD (8421) | Excess-3 Code () | 1’s Comp of XS-3 | 9’s Comp Digit () | XS-3 Code of () |
|---|---|---|---|---|---|
| 0 | 0000 | 0011 | 1100 | 9 | 1100 |
| 1 | 0001 | 0100 | 1011 | 8 | 1011 |
| 2 | 0010 | 0101 | 1010 | 7 | 1010 |
| 3 | 0011 | 0110 | 1001 | 6 | 1001 |
| 4 | 0100 | 0111 | 1000 | 5 | 1000 |
| 5 | 0101 | 1000 | 0111 | 4 | 0111 |
| 6 | 0110 | 1001 | 0110 | 3 | 0110 |
| 7 | 0111 | 1010 | 0101 | 2 | 0101 |
| 8 | 1000 | 1011 | 0100 | 1 | 0100 |
| 9 | 1001 | 1100 | 0011 | 0 | 0011 |
6. Design: BCD to Excess-3 Code Converter
Major Exam Design Problem (PYQ 2018 — 10 marks; also ECE 2104 Lab Week 4)
Question: Design a combinational logic circuit that converts a 4-bit BCD input () to a 4-bit Excess-3 code output ().
Step 1: Truth Table
Inputs – can never occur in BCD, so all four outputs are don’t cares () for those rows — this is what makes the simplification collapse so neatly.
| Decimal | ||||||||
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 2 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 |
| 3 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | 0 |
| 4 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 |
| 5 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 |
| 6 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 1 |
| 7 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 0 |
| 8 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 |
| 9 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| 10–15 | — | — | — | — |
Step 2: Minterm Lists (for plotting the four K-maps)
Step 3: Minimised Output Equations
- Output (LSB):
- Output :
- Output :
- Output (MSB):
Why these equations are worth memorising
The two XOR-style forms — and — let you draw the whole converter with roughly 4 gates instead of 12. Writing the unfactored SOP is not wrong, but the factored version is what the examiner is fishing for, and it is also the version you physically build in the ECE 2104 lab.
Sanity check in one line: Excess-3 is just , so the LSB must always flip (). If your comes out as anything else, you have mis-plotted the map.
Past Year Questions (PYQs)
Question (as asked) Years Marks Solved in Define self-complementary code (asked inside a multi-part “Define the following terms” question) 2017 part of 10 §Abstract What is self-complementary code? “Excess-3 code is a self-complementary code” — justify 2021, 2023, 2025 8–10 §3 Design a BCD to Excess-3 code converter 2018 10 §6 Pattern to notice: the self-complementing proof has appeared in three of the last five papers and the wording is near-identical each time. It is one of the highest-certainty questions in the whole course — the full derivation is only four lines, so there is no reason to lose these marks.
Related weighted-code version of the same idea (weights must sum to 9) is proved in §4 and can be swapped in if the examiner asks about 2421 or 84-2-1 instead.