Binary-coded decimal (BCD) addition is similar to normal binary addition, except the result must be corrected to BCD form whenever the binary value of any decimal digit exceeds . The correction: add to any invalid BCD result.

Why a correction is needed

In BCD, each decimal digit is encoded in 4 bits. But 4 bits can represent through — so through are invalid BCD codes (they don’t correspond to any decimal digit). Whenever an addition produces one of these invalid codes, BCD arithmetic gets the wrong answer unless we correct.

Adding pushes the result past the invalid range and back into valid BCD, with the appropriate carry into the next digit position.

Worked example

Add in BCD:

The binary result equals — correct in pure binary, but is an invalid BCD code. Add to correct:

Read in BCD: is the tens digit, is the ones digit, so . ✓

The correction rule

For the result of a 4-bit addition, the true BCD sum bit pattern and the carry-out :

  • If : and . No correction.
  • If : and . Correction applied.

A useful detection trick: iff there’s a carry-out from the 4-bit adder OR ( AND ( OR )).

Why this works: the carry-out from a 4-bit adder fires when the sum is at least , i.e. — that catches all sums of two BCD digits that overflow past 4 bits. The remaining "" cases without overflow are , with bit patterns . Each of these has along with at least one of or set. Bit patterns and () have but , so the trick correctly excludes them. Adding only affects the middle bits — doesn’t disturb the LSB or MSB of .

Implementation

A single-digit BCD adder consists of:

  1. A 4-bit binary adder for the initial sum.
  2. Detection logic that flags whether .
  3. A 4-bit corrective adder that adds when the flag is set.

For multi-digit BCD numbers, chain single-digit BCD adders just like ripple-carry binary adders, with each stage’s feeding the next stage’s .

When BCD is used

BCD is wasteful — 4 bits represent only 10 of 16 patterns. Pure binary is more efficient. But BCD is preferred where decimal precision matters and rounding errors from binary representation are unacceptable:

  • Financial calculations: dollar amounts must be exact to the cent.
  • Calculator chips: traditionally use BCD for exact decimal display.
  • Time/date calculations: hours, minutes, days are decimal-natural.
  • Some database systems: SQL DECIMAL types use BCD-like encoding.

For the underlying adder hardware, see that note. For character codes like ASCII, the lower 4 bits of digit characters happen to encode BCD — see that note.