A-Level Computer Science / Unit 1: Representing Information

1.1.4 Binary Coded Decimal

πŸ”’ Lesson slides are available to signed-in users. Sign in

1.1.4 Binary Coded Decimal

Binary Coded Decimal (BCD) represents each denary digit with its own 4-bit code. This is different from ordinary binary, where the complete number is converted as one value.

This section develops the topic through encoding, decoding, storage choices, applications, and corrected BCD addition.

By the end of this section, you should be able to:

  • encode and decode denary values using BCD;
  • identify valid and invalid BCD nibbles;
  • distinguish ordinary binary from BCD;
  • compare packed and unpacked BCD;
  • explain suitable uses of BCD;
  • apply the correction rule during BCD addition.

Exam focus

The strongest definition explains the method: each denary digit is encoded separately using four bits.

Encoding Individual Digits

BCD uses one nibble for each denary digit. The ordinary 4-bit binary values for 0 to 9 are used as the digit codes.

Binary Coded Decimal: a digit-based representation in which every denary digit is encoded independently as a 4-bit binary value.
Denary digit BCD code Denary digit BCD code
0000050101
1000160110
2001070111
3001181000
4010091001

The six remaining 4-bit patterns, from 1010 to 1111, do not represent denary digits in standard BCD.

Common mistake

A 4-bit pattern can be valid binary without being valid BCD. For example, 1100 is binary 12, but it is not a valid single BCD digit.

Encoding Multi-Digit Values

To encode a number with several digits, separate the denary digits first and convert each one independently.

Worked example: encode 573

Denary digit BCD nibble
50101
70111
30011

Therefore: 573 β†’ 0101 0111 0011

Decoding BCD

Split the bit pattern into nibbles and read each nibble as one denary digit.

For example: 1000 0010 0110 β†’ 8, 2, 6 β†’ 826

Exam tip

Preserve the nibble boundaries in your working. Writing spaces between groups of four bits makes the method clear.

BCD Compared with Ordinary Binary

BCD and ordinary binary can represent the same denary value, but they use different encoding methods.

Value Ordinary binary BCD
58 111010 0101 1000
91 1011011 1001 0001

Ordinary binary usually uses fewer bits. BCD is useful when the system needs to preserve or manipulate separate decimal digits.

Why not extract the decimal digit from ordinary binary?

A calculator has calculated the answer 156 and needs to show it on its display. In ordinary binary:

156 β†’ 10011100

The binary pattern represents the complete value. There is no group of bits that simply means β€œthe digit 5”. To find the tens digit, the system must first convert or process the binary value to recover its decimal digits.

The important trade-off:
Ordinary binary uses storage efficiently, but decimal digits are not directly available.
BCD uses more bits, but each decimal digit is already separated.

A program could certainly calculate the required digit. For example, it could repeatedly divide by 10, use remainders, or use another binary-to-decimal conversion algorithm. However, this requires additional computation and, in simple hardware, additional logic.

With BCD, the same value is stored as:

156 β†’ 0001 0101 0110

Now the tens digit is immediately available as the middle nibble: 0101 β†’ 5. The system can select those four bits directly instead of first converting the complete binary value back into decimal digits.

Common misconception

BCD is not more storage-efficient than ordinary binary. Its advantage is that decimal digits are easier to access and send to digit-based devices, such as decimal counters and display controllers.

Common misconception

Converting a complete denary value into binary does not produce BCD. BCD starts by separating the denary digits.

Packed and Unpacked BCD

BCD digits may be stored in two common ways.

Method Storage arrangement Example using 5814
Unpacked BCD One digit is placed in each byte. 00000101 00001000 00000001 00000100
Packed BCD Two digit nibbles share each byte. 01011000 00010100
Packed BCD: two BCD digits stored in one byte.
Unpacked BCD: one BCD digit stored in each byte.

Comparison point

Packed BCD uses storage more efficiently because both nibbles in a byte carry digit information.

Where BCD Is Useful

BCD is most useful when a system works naturally with decimal digits rather than only with whole binary values.

Context Why BCD can be suitable
Seven-segment display controller Each decimal digit can be passed directly to a display stage.
Electronic meter Readings are presented as a sequence of decimal digits.
Financial calculation Decimal digits can be preserved exactly instead of relying on an approximate binary fraction.
Timer or counter Each displayed position can be updated as an individual digit.

Balanced answer

BCD is convenient for decimal digit processing, but it is less space-efficient than ordinary binary.

Interactive: BCD Encoder

Type a denary value. The tool shows how each digit becomes a BCD nibble and how the result can be arranged in packed or unpacked form.

Unpacked BCD: --
Packed BCD: --

Why BCD Addition Needs Correction

BCD digits are stored as binary nibbles, so the hardware first performs binary addition. A nibble result may then fall outside the valid BCD range of 0000 to 1001.

BCD correction: add 0110 when a digit sum is greater than 9 or when a carry leaves the nibble.

Worked example: 0.38 + 0.47

The expected denary result is 0.85.

Stage Calculation Decision
Hundredths 1000 + 0111 = 1111 15 is not a valid BCD digit.
Correct the nibble 1111 + 0110 = 1 0101 Store 0101 and carry 1.
Tenths 0011 + 0100 + 0001 = 1000 8 is valid, so no correction is required.

Final BCD result: 1000 0101 β†’ 0.85

Common mistake

Do not correct every nibble automatically. Apply the correction only when the binary sum is not a valid BCD digit or produces a carry out.

Interactive: BCD Addition Visualiser

The visualiser processes the digits from right to left and shows where a correction and decimal carry are required.

BCD Representation

First value: --
Second value: --

Step-by-step working

Final result: --

Practice and Review

Try these questions

  1. Encode 694 as BCD.
  2. Decode 0011 1001 0100.
  3. Explain why 1011 is not a valid BCD digit.
  4. Write 5814 in packed BCD.
  5. Write 72 in unpacked BCD.
  6. Compare the ordinary binary and BCD representations of 46.
  7. Give one suitable application of BCD and justify your choice.
  8. Calculate 0.38 + 0.47 using corrected BCD addition.

Final checklist

  • Convert each denary digit separately.
  • Keep clear nibble boundaries.
  • Reject nibble values from 1010 to 1111.
  • State packed or unpacked when storage is discussed.
  • Check every digit sum during BCD addition.