Skip to content

Latest commit

 

History

History
115 lines (76 loc) · 3.62 KB

File metadata and controls

115 lines (76 loc) · 3.62 KB

Chapter 10: Binary Coded Decimal (BCD)

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.


Overview

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.


Definitions

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.


Advantages of BCD

  1. Exact Decimal Representation: BCD allows for the exact representation of decimal numbers, making it ideal for applications requiring high precision, such as financial calculations.
  2. Simplified Arithmetic: BCD arithmetic can be simpler than binary arithmetic, as each digit is processed independently.
  3. Easier Human Readability: BCD-encoded numbers are more easily interpreted by humans, as they closely resemble their decimal counterparts.

Disadvantages of BCD

  1. 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).
  2. 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.

Applications of BCD

  1. Digital Clocks: BCD is commonly used in digital clocks to represent the time in a human-readable format.
  2. Financial Calculators: BCD is used in financial calculators to ensure accurate decimal representation and avoid rounding errors.
  3. Embedded Systems: BCD is often used in embedded systems where exact decimal representation is required, such as in automotive and industrial applications.

Summary

  1. BCD represents each decimal digit (0-9) with a 4-bit binary code.
  2. Advantages: Exact decimal representation, simplified digit-wise arithmetic, human-readable.
  3. Disadvantages: Inefficient space usage, complex multi-digit operations.
  4. Applications: Digital clocks, financial calculators, embedded systems.

Examples

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.