Circle D Converter

Convert between Decimal and BCD (Binary Coded Decimal) - The 8421 Code

Conversion Type
Enter any positive integer (0-9999 for 16-bit BCD)
Options
Conversion Result

What is BCD (Binary Coded Decimal)?

BCD (Binary Coded Decimal) is a method of encoding decimal numbers where each decimal digit is represented by its 4-bit binary equivalent. It's also known as the 8421 code because the bits represent values 8, 4, 2, and 1.

Example: Decimal 1234 = BCD: 0001 0010 0011 0100

BCD Encoding Table

DecimalBCDDecimalBCD
0000050101
1000160110
2001070111
3001181000
4010091001

Applications of BCD

  • 📺 Seven-segment displays (digital clocks)
  • 🧮 Calculators and digital counters
  • 💻 Real-time clocks (RTCs)
  • 🔢 Microprocessor applications
  • 📊 Financial calculations (prevents floating-point errors)
Frequently Asked Questions
What is Circle D or BCD Code?

BCD (Binary Coded Decimal), also known as Circle D or 8421 code, is a method of representing decimal numbers using binary. Each decimal digit (0-9) is represented by its 4-bit binary equivalent. For example, the decimal number 42 is represented as 0100 0010 in BCD. This representation makes it easier for digital circuits to display decimal numbers directly.

Why use BCD instead of pure binary?

BCD is preferred in applications like digital clocks, calculators, and seven-segment displays because:

  • It's easier to convert to decimal for display purposes
  • Each digit is represented independently
  • No rounding errors in decimal arithmetic
  • Simpler hardware implementation for decimal display
  • Easier for humans to read and debug
What is the range of BCD numbers?

With n bits, BCD can represent 10^(n/4) decimal digits. For example:

  • 4-bit BCD: 0 to 9 (1 digit)
  • 8-bit BCD: 0 to 99 (2 digits)
  • 12-bit BCD: 0 to 999 (3 digits)
  • 16-bit BCD: 0 to 9999 (4 digits)

This converter supports up to 4-digit (16-bit) BCD numbers.

What is the difference between BCD and binary?

In pure binary, the entire number is converted as one binary value. In BCD, each decimal digit is converted separately to 4-bit binary. For example:

  • Decimal 42 in binary: 101010 (6 bits)
  • Decimal 42 in BCD: 0100 0010 (8 bits)

BCD uses more bits but is easier to convert to decimal for display.

What are invalid BCD codes?

In standard BCD, only binary values from 0000 to 1001 (0-9) are valid. Values from 1010 to 1111 (10-15) are invalid BCD codes. These are sometimes used for error detection or special purposes, but they don't represent valid decimal digits.

What is the 8421 code?

8421 refers to the weight of each bit in the 4-bit BCD representation:

  • The leftmost bit (most significant) has weight 8
  • The second bit has weight 4
  • The third bit has weight 2
  • The rightmost bit (least significant) has weight 1

For example, the BCD code 1001 represents: 1×8 + 0×4 + 0×2 + 1×1 = 9

How do I convert decimal to BCD?

To convert decimal to BCD:

  1. Separate the decimal number into individual digits
  2. Convert each digit to its 4-bit binary equivalent
  3. Combine the 4-bit groups in order

Example: Decimal 1234 → Digits: 1, 2, 3, 4 → BCD: 0001 0010 0011 0100

How do I convert BCD to decimal?

To convert BCD to decimal:

  1. Split the BCD code into 4-bit groups
  2. Convert each 4-bit group to its decimal equivalent (0-9)
  3. Combine the decimal digits in order

Example: BCD: 0001 0010 0011 0100 → Groups: 0001(1), 0010(2), 0011(3), 0100(4) → Decimal: 1234

What is packed vs unpacked BCD?

Unpacked BCD: Each decimal digit is stored in a separate byte (8 bits), with the upper 4 bits unused (often set to 0).

Packed BCD: Two decimal digits are stored in each byte (4 bits per digit). This is more memory-efficient.

This converter uses packed BCD representation (4 bits per digit).

Can I use this converter for 8-bit, 16-bit, or 32-bit BCD?

Yes! This converter supports BCD numbers of any length. Just enter the complete BCD code as a continuous string or space-separated groups. The converter will automatically detect the number of digits. Common lengths include:

  • 8-bit BCD: 2 decimal digits (0-99)
  • 16-bit BCD: 4 decimal digits (0-9999)
  • 32-bit BCD: 8 decimal digits (0-99999999)