💾 BCD Converter

🔄
📝
{{ getInputHint() }}
🎨
📖
💡
123 → 0001 0010 0011
456 → 0100 0101 0110
9876 → 1001 1000 0111 0110
0001 0010 0011 → 123
000100100011 → 123
0x123 → 123
📤
{{ output }}
🔍
Digit {{ item.digit }}: {{ item.bcd }}
({{ item.decimal }} in decimal)
📊
Decimal BCD
00000
10001
20010
30011
40100
Decimal BCD
50101
60110
70111
81000
91001
Note: BCD codes 1010-1111 are invalid (not used in standard BCD encoding)
ℹ️
Nibbles: Each 4-bit code separated by spaces (0001 0010 0011)
Continuous: All bits in one string (000100100011)
Hexadecimal: BCD interpreted as hex digits (0x123 or 123)
Advantage: Direct decimal-to-binary mapping without binary arithmetic
⚠️

ℹ️ About BCD Converter

Binary Coded Decimal (BCD) is a decimal-preserving binary representation: each base-10 digit is encoded as its own 4-bit nibble. For example, decimal 12 becomes 0001 0010 in BCD, not the pure binary value 1100.

This converter handles unsigned 8421-style BCD digit encoding, with decimal-to-BCD and BCD-to-decimal modes. It accepts grouped nibbles such as 0001 0010 0011, continuous bit strings such as 000100100011, or hexadecimal shorthand such as 0x123.

Common BCD use cases:

  • Displaying decimal digits on seven-segment displays, counters, clocks, calculators, and measurement equipment.
  • Debugging microcontroller registers, embedded protocols, or hardware interfaces that store decimal digits directly.
  • Reading legacy mainframe, COBOL, and packed-decimal data formats where each digit occupies a nibble.
  • Teaching the difference between digit encoding and true binary number conversion.
  • Checking decimal identifiers that must keep leading zeroes visible during conversion.

Digit mapping:

  • 0: 0000 | 1: 0001 | 2: 0010 | 3: 0011 | 4: 0100
  • 5: 0101 | 6: 0110 | 7: 0111 | 8: 1000 | 9: 1001
  • Invalid digit nibbles: 1010 through 1111 are rejected by this tool because ordinary unsigned BCD only represents decimal digits 0-9.

Examples: 123 encodes to 0001 0010 0011; 9075 encodes to 1001 0000 0111 0101; 0x420 decodes back to decimal 420.

Limitations: BCD is not a general binary base converter and this page does not perform BCD arithmetic. Signed packed decimal, zoned decimal, decimal floating-point, and dense packed decimal formats can add sign nibbles, zone bits, scale, or compression rules that need format-specific parsing. This converter intentionally limits input to 16 decimal digits or 16 BCD nibbles.

Privacy note: The interactive conversion runs locally in your browser as you type. If you use the public API endpoint instead, the submitted input is sent to the server for processing.

References: NIST CSRC glossary entry for Binary Coded Decimal and IBM documentation on compressed BCD values provide useful background on BCD terminology and packed digit storage.

API Usage Example:

POST /api/tools/conversion/bcd
Content-Type: application/json

{
    "input": "123",
    "mode": "decimal-to-bcd",
    "outputFormat": "nibbles",
    "inputFormat": "nibbles"
}
Ready