Originally created 27 February 2021, by Maxwell Hauser — Updated 7 October 2025.
Builds upon material from Chapter 7: Unsigned, Signed Magnitude and Signed Two's Complement Binary Numbers and Chapter 8: Binary Addition.
We often use decimal numbers in our daily lives. In computers, however, numbers are typically represented in binary format. Binary Coded Decimal (BCD) is a method of representing decimal numbers in binary form, from 0 to 9, where 0 is represented by 0000 and 9 is represented by 1001.
BCD Encoding Table:
| Decimal | BCD |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
Binary Coded Decimal (BCD) is a class of binary encodings of decimal numbers where each digit is represented by its own binary sequence. BCD is used in digital systems where exact decimal representation is required, such as in financial calculations and digital clocks.
In BCD, each decimal digit is represented by a fixed number of bits, typically four or eight. The most common BCD representation is 4-bit BCD, where each digit from 0 to 9 is represented by its binary equivalent.
Example: The decimal number 45 would be represented in 4-bit BCD as:
4: 0100
5: 0101
So, 45 in BCD is 0100 0101.
- Exact Decimal Representation: BCD allows for the exact representation of decimal numbers, making it ideal for applications requiring high precision, such as financial calculations.
- Simplified Arithmetic: BCD arithmetic can be simpler than binary arithmetic, as each digit is processed independently.
- Easier Human Readability: BCD-encoded numbers are more easily interpreted by humans, as they closely resemble their decimal counterparts.
- Inefficient Use of Space: BCD requires more bits to represent decimal numbers compared to pure binary representation. For example, the decimal number 45 requires 8 bits in BCD (4 bits for each digit) but only 6 bits in binary (00101101).
- Complex Arithmetic Operations: While BCD arithmetic can be simpler for individual digits, it can be more complex for multi-digit operations, requiring additional logic to handle carries and borrows.
- Digital Clocks: BCD is commonly used in digital clocks to represent the time in a human-readable format.
- Financial Calculators: BCD is used in financial calculators to ensure accurate decimal representation and avoid rounding errors.
- Embedded Systems: BCD is often used in embedded systems where exact decimal representation is required, such as in automotive and industrial applications.
- BCD represents each decimal digit (0-9) with a 4-bit binary code.
- Advantages: Exact decimal representation, simplified digit-wise arithmetic, human-readable.
- Disadvantages: Inefficient space usage, complex multi-digit operations.
- Applications: Digital clocks, financial calculators, embedded systems.
Example 1: Convert 345 to BCD
3: 0011
4: 0100
5: 0101
So, 345 in BCD is 0011 0100 0101.
Example 1.21: Convert (0101 0001 0010)BCD to decimal:
5: 0101
1: 0001
2: 0010
So, (0101 0001 0010)BCD is 512 in decimal.
Example 1.22: Add (0011 0100)BCD and (0001 0110)BCD:
0011 0100
+ 0001 0110
---------
0100 1010
So, (0011 0100)BCD + (0001 0110)BCD is (0100 1010)BCD, which is 58 in decimal.