Skip to content

Syllabus · CS Computer Science and Information Technology

All topics in this subject
C programming foundations6
Arrays and pointers7
Recursion6
Probability and statistics foundations9
Linked lists, stacks and queues3
Trees, BSTs and heaps3
Graph foundations3
Algorithms foundations3
Discrete mathematics foundations15
Digital logic foundations22
Computer organization foundations12
Operating systems foundations6

BCD digit arithmetic and excess-three conversion

Lesson 58 of 958 minFree

Decimal digits stored in binary fields

A representation must specify what each field means. In unsigned 8421 binary-coded decimal (BCD), each decimal digit is separately encoded using four binary bits. Valid digit codes are 0000 through 1001. The six patterns 1010 through 1111 are not valid BCD digits, even though they are ordinary four-bit binary integers.

Prerequisites: binary/hexadecimal representation, adders, Boolean conditions and multiplexers. BCD and excess-three are selected code/arithmetic implementations within the syllabus's broad topics, not additional named syllabus clauses. This lesson uses unsigned decimal digits only; packed sign nibbles, decimal floating point and signed decimal subtraction are outside its contract.

Worked example 1: decimal 73 is BCD 0111 0011, one nibble for 7 and one for 3. Reading that entire bit string as an unsigned binary integer instead gives 0x73=115. Decimal 73 as ordinary eight-bit binary is 01001001. These are different encodings of the same intended number, not interchangeable bit patterns.

For k BCD digits d_(k−1)…d_0, value=Σ d_i10^i and storage is 4k bits. There are 10^k valid digit strings among 16^k possible patterns. Two BCD digits cover 00…99 using eight bits: 100 valid patterns among 256. Leading decimal zeros are allowed here. Four digits need sixteen bits, but their maximum is 9999, not 65535.

Detect an invalid digit

For nibble b_3b_2b_1b_0, values 10…15 are exactly those with b_3=1 and at least one of b_2,b_1 equal to 1. Thus invalid=b_3 AND (b_2 OR b_1); valid is its complement. The bit b_0 does not affect validity. Both 8=1000 and 9=1001 are valid even though their top bit is one.

If invalid inputs can occur, define an error flag or explicit output behavior. Treating invalid codes as minimization don't-cares is justified only when the input contract excludes them. It does not implement an invalid-input detector automatically. We will restrict the digit adder to valid input digits and separately give a converter defined on all sixteen inputs.

One-digit BCD addition

Let a,b be valid decimal digits 0…9 and c_in∈{0,1} be an incoming decimal carry. The exact integer total t=a+b+c_in lies in 0…19. First use a four-bit binary adder to obtain low nibble z and binary carry k, so t=16k+z.

A decimal correction is required exactly when t≥10. For valid inputs, its Boolean signal is

c_dec = k OR [z_3 AND (z_2 OR z_1)].

If c_dec=1, add 0110 to z and retain four bits; otherwise retain z. The final decimal carry is c_dec, and the corrected digit is d=(z+6c_dec) mod 16. Why six? A binary nibble wraps at 16, while a decimal digit should wrap at 10; 16−10=6 aligns those boundaries.

Prove the three possible ranges. If t≤9, k=0 and no correction gives d=t,c_dec=0. If 10≤t≤15, z=t; adding six wraps to t−10 with carry one. If 16≤t≤19, k=1,z=t−16; adding six gives t−10 between 6 and 9, without a new carry from that second addition. In every case t=10c_dec+d and 0≤d≤9. This proof also shows why the correction adder's carry alone is not always the final decimal carry.

Worked example 2: 6+7+1=14. Binary first sum is 0 1110. Since z>9, correction adds 0110: 1110+0110=1 0100. Result is decimal carry 1,digit 4, representing 14.

Worked example 3: 9+8+1=18. First sum is 1 0010, so k=1 and correction is necessary even though low nibble 0010≤9. Add six: 0010+0110=1000. The second adder has no carry, but decimal carry remains c_dec=1. Final digits are 1 and 8. Testing only z>9 or discarding the first carry would fail here.

Cascade decimal carries, not arbitrary binary flags

For a multi-digit adder, process from units upward, feeding each c_dec to the next decimal digit. Each stage applies its own correction. A final carry adds one more decimal digit; it indicates overflow only if the destination has a fixed number of decimal digits that cannot grow.

Worked example 4: 47+58. Units: 7+8=15, so store 5 and pass carry 1. Tens: 4+5+1=10, so store 0 and pass carry 1. A three-digit result is 105, BCD 0001 0000 0101. A two-digit destination retains 05 and has final decimal carry 1; that is not an exact representation of 105. Applying one correction to the entire eight-bit raw sum would not implement the per-digit contract.

Excess-three as a declared code conversion

Excess-three stores digit d as the four-bit binary value d+3. Thus valid codes run from 0011 for zero through 1100 for nine. This is not 8421 BCD; code 1001 means digit 6 in excess-three, not digit 9.

Decimal digitBCDExcess-three
000000011
100010100
200100101
300110110
401000111
501011000
601101001
701111010
810001011
910011100

A complete BCD-to-excess-three circuit can use the validity detector, an adder for b+3, and an output MUX. Our defined interface returns v=1 and b+3 for valid BCD b; otherwise v=0 and fixed output 0011. The fixed output is a safe declared placeholder, not a claim that invalid input numerically meant zero. The flag distinguishes it from a valid input zero. No state storage is needed; this is component-level combinational composition.

To decode excess-three, first check 3≤u≤12, then return u−3. Worked example 5: BCD 0110→1001; decode unsigned 9−3=6. Complementing all four excess-three bits maps a digit to its nine's complement: 15−(d+3)=12−d=(9−d)+3. So complement of 1001 is 0110, the excess-three code for digit 3=9−6. This self-complementing property is about decimal digit coding, not two's-complement signed negation.

Key points and checking strategy

Do not interpret a multi-digit BCD string using powers of sixteen. Reject or explicitly define invalid digits. Keep first binary carry, correction-adder carry and decimal carry distinct. Verify all 10×10×2=200 valid digit-addition cases against t=10c_dec+d. Verify all sixteen converter inputs, including six invalid cases, and all ten valid round trips. Matching a few examples is weaker than exhausting these small domains.

Original practice

These six single-correct MCQs are original learning questions, not previous-year questions. Choose exactly one option.

C01. What is decimal 73 in unsigned 8421 BCD?

A. 0100 1001 B. 0111 0011 C. 0111 1010 D. 1001 0011

Answer: B

A is incorrect: that is ordinary binary 73, but BCD digits 4 and 9.

B is correct: encode decimal digits 7 and 3 separately.

C is incorrect: nibble 1010 is not a valid BCD digit.

D is incorrect: its BCD digits are 9 and 3, giving 93.

C02. How many valid two-digit unsigned BCD patterns exist in eight bits, including leading zero?

A. 256 B. 99 C. 100 D. 200

Answer: C

A is incorrect: 256 includes nibbles 10…15, which BCD excludes.

B is incorrect: it omits the valid 00 pattern.

C is correct: each of two digits has ten choices, giving 10²=100.

D is incorrect: digit choices multiply, not add and double.

C03. For valid BCD digits 9 and 8 with c_in=1, what are the corrected digit, decimal carry and second-adder carry?

A. 8,1,0 B. 2,1,0 C. 8,0,0 D. 2,0,1

Answer: A

A is correct: t=18 gives k=1,z=2; 2+6=8 without a second carry, while decimal carry is one.

B is incorrect: it fails to correct the low nibble.

C is incorrect: the first carry already requires decimal carry one.

D is incorrect: both the digit and carry interpretation are wrong.

C04. A two-digit BCD destination adds 47+58. What are retained decimal digits and final decimal carry?

A. 15 and 0 B. 05 and 0 C. 99 and 1 D. 05 and 1

Answer: D

A is incorrect: the exact sum is 105, not 15.

B is incorrect: retained 05 is correct but the hundreds carry must be one.

C is incorrect: the stated adder retains digits, not a saturation value.

D is correct: 105 leaves 05 with one additional hundreds carry.

C05. Complement all bits of excess-three code 1001. Which decimal digit does the result represent?

A. 6 B. 3 C. 9 D. −6

Answer: B

A is incorrect: six is the original digit, not its nine's complement.

B is correct: complement is 0110, unsigned 6; excess-three decoding gives 6−3=3.

C is incorrect: code for nine is 1100.

D is incorrect: the code has unsigned decimal-digit semantics, not signed negation.

C06. Our fully defined converter gives (v,b+3) for valid BCD b and (0,0011) otherwise. What does input 1010 produce?

A. (1,1101) B. (1,0011) C. (0,0011) D. No output is defined

Answer: C

A is incorrect: 1010 is invalid BCD, so the valid arithmetic path is not selected.

B is incorrect: the placeholder is selected but v must report invalidity.

C is correct: invalid=1 AND(0 OR1)=1, selecting v=0 and the declared placeholder.

D is incorrect: the contract explicitly covers all sixteen input patterns.

Scope and sources

This is one bounded Digital Logic lesson, not complete GATE CS coverage. The official syllabus establishes relevance only; the derivations, examples and practice are original. Technical references were used to check representation and circuit conventions, not to reproduce their exercises.

Sources checked 14 October 2026.

Sign in to keep your progress. Sign in