TFT

BCD (Binary-Coded Decimal) Converter

Convert decimal numbers to Binary-Coded Decimal (BCD) format, where each digit is represented by 4 bits, or convert BCD back to decimal. Used in digital systems and financial applications.

BCD (Binary Coded Decimal) Converter

Convert between decimal numbers and Binary Coded Decimal format

About BCD

Binary Coded Decimal (BCD) represents each decimal digit (0-9) using 4 bits (a nibble). It's commonly used in digital displays, calculators, and financial applications where exact decimal representation is important.

Packed BCD stores two digits per byte (more efficient), while Unpacked BCD stores one digit per byte (simpler to process).

How the BCD Converter Works

Enter a decimal number to convert to Binary-Coded Decimal (BCD), or input BCD to convert back to decimal. The conversion happens instantly as you type.

Each decimal digit (0-9) is represented by exactly 4 bits in BCD. For example, decimal 25 becomes 0010 0101 in BCD - each digit encoded separately, not as pure binary.

Choose between packed BCD (two digits per byte) or unpacked BCD (one digit per byte). Packed is more space-efficient. Unpacked is simpler for some hardware interfaces.

When You'd Actually Use This

Working with digital clocks

RTC chips often store time in BCD format. Hours, minutes, seconds each use one byte in packed BCD. Convert to decimal for display or calculation.

Reading 7-segment displays

7-segment display drivers accept BCD input. Each digit's segment pattern corresponds to BCD values. Convert decimal to BCD for display control.

Processing financial data

Some financial systems use BCD for exact decimal representation. Avoids floating-point rounding errors. Convert BCD to decimal for calculations.

Interfacing with PLCs

Industrial PLCs often use BCD for numeric I/O. Thumbwheel switches output BCD. Seven-segment displays expect BCD. Convert for proper interfacing.

Decoding barcode data

Some barcode formats encode digits in BCD. Decode the barcode to BCD first, then convert to decimal or ASCII for the actual data.

Working with legacy systems

Older mainframes and minicomputers used BCD extensively. COBOL programs often store numbers in BCD. Convert for modern system integration.

What to Know Before Using

BCD uses more bits than pure binary.4 bits can represent 0-15, but BCD only uses 0-9. Values 10-15 (A-F) are invalid in BCD. This wastes some encoding space but simplifies decimal conversion.

Packed vs unpacked affects storage.Packed BCD stores two digits per byte (0-99). Unpacked stores one digit per byte (0-9). Packed halves the storage requirement.

BCD avoids rounding errors.Binary floating-point can't exactly represent many decimals. BCD represents decimals exactly. Important for financial calculations.

Invalid BCD values exist.Binary values 1010-1111 (A-F hex) are invalid in BCD. If you see these, the data isn't valid BCD or uses a different encoding.

Pro tip: When reading BCD from hardware, verify each nibble is 0-9. Invalid values indicate communication errors or wrong byte order. Always validate BCD input.

Common Questions

What's the difference from regular binary?

Binary 25 is 11001. BCD 25 is 0010 0101 (2 and 5 separately). Binary is more compact. BCD converts to decimal digits more easily.

Why use BCD instead of binary?

BCD simplifies decimal display and input. No division needed to extract digits. Hardware for 7-segment displays works directly with BCD.

Can BCD represent negative numbers?

Standard BCD doesn't include sign. Some systems use a separate sign byte or reserve one nibble for sign (C for +, D for -).

What's zoned decimal?

Zoned decimal is unpacked BCD with zone bits. Each byte has a zone (high nibble) and digit (low nibble). Common in IBM mainframes.

How do I calculate with BCD?

Convert to decimal first, calculate, then convert back. Some CPUs have BCD arithmetic instructions. Software BCD math is complex and slow.

Where is BCD still used today?

RTC chips, digital meters, industrial controls, financial systems, and legacy mainframe applications. Less common in modern computing but still relevant.

What's the maximum BCD value?

Depends on how many digits you have. One byte packed BCD: 99. Two bytes: 9999. Each additional byte adds two more decimal digits.