BCD to ASCII Converter
Convert BCD (Binary-Coded Decimal) to ASCII text online. Supports packed BCD, unpacked BCD, and EBCDIC modes with binary, hex, and decimal input formats.
| # | Input Byte | Binary | Nibble(s) | Digit(s) | ASCII | Status |
|---|
About
Binary-Coded Decimal (BCD) encodes each decimal digit into a fixed number of binary bits, typically 4 bits per digit. Misinterpreting BCD data as straight binary produces values that drift silently from the intended decimal - a class of bug that corrupts financial records, sensor telemetry, and legacy mainframe data without triggering obvious errors. This tool decodes both packed BCD (two digits per byte, 8 bits total) and unpacked BCD (one digit per byte, upper nibble zeroed or zoned) into readable ASCII text. It also handles EBCDIC-coded decimal mapping for mainframe interchange scenarios.
Conversion validates every nibble against the legal BCD range 0000 - 1001 (decimal 0 - 9). Nibbles outside this range - 1010 through 1111 - are flagged as invalid rather than silently truncated. The tool accepts binary, hexadecimal, and decimal byte representations. Note: this converter assumes unsigned BCD with no sign nibble. Signed BCD variants (where the last nibble encodes sign) require separate handling.
Formulas
Packed BCD stores two decimal digits in a single 8-bit byte. The upper nibble holds the tens digit, the lower nibble holds the units digit. Extraction and ASCII conversion proceed as follows:
Where dhigh is the upper nibble (bits 7 - 4), dlow is the lower nibble (bits 3 - 0), and 0x30 (48 decimal) is the ASCII code for the character "0". Each nibble must satisfy 0 ≤ d ≤ 9; any value outside this range is not a valid BCD digit.
For unpacked BCD, each byte carries one digit in the lower nibble. The upper nibble is typically a zone field - 0011 in ASCII-zoned BCD (0x30 - 0x39) or 1111 in EBCDIC-zoned BCD (0xF0 - 0xF9). The conversion strips the zone:
Where byte is the full 8-bit unpacked BCD value. The result d is then converted to ASCII by adding 0x30.
Reference Data
| Decimal Digit | BCD (4-bit) | Unpacked BCD Byte (Hex) | Packed BCD (2 digits/byte example) | ASCII Code (Dec) | ASCII Char |
|---|---|---|---|---|---|
| 0 | 0000 | 0x30 | 0x00 (with 0) | 48 | 0 |
| 1 | 0001 | 0x31 | 0x01 | 49 | 1 |
| 2 | 0010 | 0x32 | 0x02 | 50 | 2 |
| 3 | 0011 | 0x33 | 0x03 | 51 | 3 |
| 4 | 0100 | 0x34 | 0x04 | 52 | 4 |
| 5 | 0101 | 0x35 | 0x05 | 53 | 5 |
| 6 | 0110 | 0x36 | 0x06 | 54 | 6 |
| 7 | 0111 | 0x37 | 0x07 | 55 | 7 |
| 8 | 1000 | 0x38 | 0x08 | 56 | 8 |
| 9 | 1001 | 0x39 | 0x09 | 57 | 9 |
| Common Packed BCD Byte Examples (two digits per byte) | |||||
| 12 | 0001 0010 | - | 0x12 | 49, 50 | 12 |
| 45 | 0100 0101 | - | 0x45 | 52, 53 | 45 |
| 78 | 0111 1000 | - | 0x78 | 55, 56 | 78 |
| 90 | 1001 0000 | - | 0x90 | 57, 48 | 90 |
| 99 | 1001 1001 | - | 0x99 | 57, 57 | 99 |
| Invalid BCD Nibbles (cause conversion errors) | |||||
| - | 1010 (A) | 0x0A | Invalid | - | Error |
| - | 1011 (B) | 0x0B | Invalid | - | Error |
| - | 1100 (C) | 0x0C | Sign nibble (+) | - | Sign |
| - | 1101 (D) | 0x0D | Sign nibble (−) | - | Sign |
| - | 1110 (E) | 0x0E | Invalid | - | Error |
| - | 1111 (F) | 0x0F | Unsigned sign / fill | - | Fill |