chevron_left Binary Coded Decimal (BCD): A coding system where each decimal digit is represented by a 4-bit binary code chevron_right

Binary Coded Decimal (BCD): A coding system where each decimal digit is represented by a 4-bit binary code
Anna Kowalski
share
visibility139
calendar_month2026-02-01

Binary Coded Decimal (BCD)

A coding system where each decimal digit is represented by a 4-bit binary code.
Summary: Binary Coded Decimal (BCD) is a clever bridge between the human-friendly decimal system and the machine-friendly binary system. In BCD, each digit of a decimal number is translated into its own group of four binary bits (bits). This means the number 42 is not stored as its full binary equivalent, but as two separate codes: one for 4 (0100) and one for 2 (0010). This system is vital for applications like digital clocks, calculators, and financial systems where accurate decimal representation is more important than pure binary efficiency. Key concepts include the 8421 weighted code, the distinction between BCD and pure binary, and the rules for BCD addition.

Why Do We Need BCD?

Computers and digital circuits operate using only two states: 0 and 1. This is the binary number system. Humans, however, naturally use the decimal number system, which has ten digits from 0 to 9. While computers can convert any decimal number into a single long binary string for calculations, this conversion is not always perfect for simple display or for handling numbers that must be exact in decimal (like money: $10.10). BCD solves this by providing a direct, digit-by-digit translation that is easy for both machines to store and for programmers to interpret as a decimal number.

Understanding the 8421 Code

The most common type of BCD is called 8421 BCD or Natural BCD. The numbers 8, 4, 2, and 1 are the weights of the four binary positions, from left to right. To find the decimal value of a 4-bit BCD code, you multiply each bit by its weight and add the results. This system directly uses the first ten binary combinations.

Decimal DigitBCD (4-bit Binary)Calculation (8-4-2-1)
00000(0x8)+(0x4)+(0x2)+(0x1)=0
10001(0x8)+(0x4)+(0x2)+(1x1)=1
20010(0x8)+(0x4)+(1x2)+(0x1)=2
30011(0x8)+(0x4)+(1x2)+(1x1)=3
40100(0x8)+(1x4)+(0x2)+(0x1)=4
50101(0x8)+(1x4)+(0x2)+(1x1)=5
60110(0x8)+(1x4)+(1x2)+(0x1)=6
70111(0x8)+(1x4)+(1x2)+(1x1)=7
81000(1x8)+(0x4)+(0x2)+(0x1)=8
91001(1x8)+(0x4)+(0x2)+(1x1)=9

Important: The binary codes for 1010 (10), 1011 (11), 1100 (12), 1101 (13), 1110 (14), and 1111 (15) are not valid in standard 8421 BCD. They are called illegal codes because a single decimal digit can never be greater than 9.

BCD vs. Pure Binary: A Clear Example

This is a crucial distinction. Let's convert the decimal number 137 into both pure binary and BCD.

Example: Converting 137
Pure Binary: We convert the entire number to base-2.
$137_{10} = 128 + 8 + 1 = 1 \times 2^7 + 0 \times 2^6 + 0 \times 2^5 + 0 \times 2^4 + 1 \times 2^3 + 0 \times 2^2 + 0 \times 2^1 + 1 \times 2^0$
So, $137_{10} = 10001001_2$ (8 bits total).

BCD: We convert each digit separately.
1 -> 0001
3 -> 0011
7 -> 0111
So, $137_{10} = 0001\ 0011\ 0111_{BCD}$ (12 bits total).

Notice that BCD used more bits (12 vs. 8)! BCD is less efficient in terms of storage but much simpler to translate back to decimal for display. You can simply take each group of 4 bits and look it up in the table above.

How to Add Numbers in BCD

Adding two BCD numbers isn't as straightforward as normal binary addition because we must ensure the result for each digit group remains a valid BCD code (0000 to 1001). If the sum of two digits is greater than 9, or if a carry is generated, we need to add a correction factor of 6 (0110 in binary) to that digit group.

Why 6? In binary, adding 6 skips over the six illegal codes (1010 to 1111) and forces a carry to the next higher decimal digit, which is exactly what we need in decimal (where 9+1=10).

Step-by-Step BCD Addition: 47 + 35
1. Write each number in BCD:
$47 = 0100\ 0111_{BCD}$
$35 = 0011\ 0101_{BCD}$
2. Add the lower (units) digit group: $0111 + 0101 = 1100$ (binary 12). This is an illegal BCD code (>9).
3. Add correction factor 6: $1100 + 0110 = 1\ 0010$. The 0010 (2) is the units digit of the result. The 1 is a carry to the next (tens) digit group.
4. Add the higher (tens) digit group PLUS the carry: $0100 + 0011 + 0001 = 1000$ (binary 8). This is a valid BCD code (≤9). No correction needed.
5. Combine the results: Tens = 1000 (8), Units = 0010 (2).
Final BCD Result: $1000\ 0010_{BCD}$, which is 82. Check: 47+35=82.

BCD in Action: Where You See It Every Day

BCD is everywhere in simple digital devices. Think about a classic digital alarm clock. The time is stored in registers as BCD values. When the circuit needs to advance the minutes from 59 to 00, it uses BCD addition logic. The BCD codes are then sent directly to the display driver chip, which lights up the correct segments for each digit. Using pure binary would require a more complex binary-to-decimal converter just to show the time on the screen.

Other common applications include:

  • Electronic Calculators: They handle each keystroke as a decimal digit, making BCD the natural choice for internal storage and operations.
  • Digital Multimeters and Weighing Scales: The numeric readout is driven directly from BCD values measured by the device.
  • Financial Systems and Monetary Calculations: To avoid rounding errors that can occur when converting decimal fractions (like $0.10) to binary, systems often use BCD or related formats to guarantee exact decimal results.

Important Questions

Q1: What is the main advantage of BCD over pure binary?
The main advantage is its simplicity and accuracy in decimal representation. Converting between BCD and human-readable decimal is trivial—you just replace each group of 4 bits with its corresponding digit. This eliminates conversion errors and is perfect for devices that primarily take decimal input and produce decimal output, like calculators and digital displays.
Q2: What is the main disadvantage of BCD?
The main disadvantage is lower storage efficiency and more complex arithmetic. BCD uses more bits to represent the same number compared to pure binary (e.g., 137 needed 12 bits in BCD vs. 8 in binary). Also, the hardware or software must include logic to handle the "+6" correction after BCD addition, making calculations slightly slower.
Q3: Are there other BCD codes besides 8421?
Yes. While 8421 is the most common, other weighted codes exist, like 2421 and 5421. There are also non-weighted codes like Excess-3 (XS-3), where the BCD code for a digit is its 8421 code plus 3 (0011). For example, decimal 0 is represented as 0011 in Excess-3. These variants have specific uses, such as simplifying subtraction circuits.
Conclusion: Binary Coded Decimal serves as an essential interpreter between the worlds of human decimal thinking and machine binary logic. Its straightforward design—mapping each decimal digit to a consistent 4-bit nibble[1]—makes it invaluable for applications where direct decimal accuracy and easy display are paramount, despite its lower data density. From the clock on your bedside table to the supermarket scale, BCD quietly ensures numbers are stored and shown exactly as we expect to see them. Understanding BCD is a fundamental step in grasping how computers represent and manipulate the numbers we use every day.

Footnote

[1] Nibble: A group of four bits. Half of a standard 8-bit byte. It is the fundamental unit of data in BCD.
[2] Binary: A base-2 number system using only two symbols, typically 0 and 1.
[3] Decimal: A base-10 number system using ten symbols, from 0 to 9.
[4] BCD: Binary Coded Decimal.
[5] Illegal Code: In standard 8421 BCD, any 4-bit pattern from 1010 (10) to 1111 (15), as they do not represent a single decimal digit.

Did you like this article?

home
grid_view
add
explore
account_circle