User Rating 0.0
Total Usage 0 times
Enter 4-bit BCD nibbles (0s and 1s, spaces optional)
Is this tool helpful?

Your feedback helps us improve.

About

Binary Coded Decimal (BCD) encodes each decimal digit 0 - 9 as a fixed-width 4-bit binary nibble. This encoding is standard in financial hardware, real-time clocks (RTCs), and BIOS date registers where decimal readability matters more than storage efficiency. A common error is treating raw BCD bit patterns as pure binary, which produces incorrect decimal values and corrupts downstream hex representations. This tool parses packed BCD input, validates that no nibble exceeds 10012 (910), reconstructs the decimal integer, and converts it to hexadecimal. It assumes standard 8421-weighted BCD. Excess-3 and Aiken codes are not supported.

bcd to hex binary coded decimal hex converter bcd converter number system conversion packed bcd

Formulas

The 8421 BCD encoding maps each decimal digit to a 4-bit nibble weighted by powers of 2. Given a BCD bit string of n nibbles, the decimal reconstruction is:

D = n1i=0 di × 10i

where di is the decimal value of the i-th BCD nibble (counting from the least significant). Each nibble is decoded as:

di = b3 × 8 + b2 × 4 + b1 × 2 + b0 × 1

A nibble is valid only if di 9. The final hexadecimal output is computed by converting the decimal integer D to base 16:

H = D.toString(16)

where D = decimal integer, H = hexadecimal string, b3b0 = individual bits in a nibble (MSB to LSB), n = number of nibbles.

Reference Data

Decimal DigitBCD (8421)Hex EquivalentExcess-3 BCDAiken (2421)
00000000110000
10001101000001
20010201010010
30011301100011
40100401110100
50101510001011
60110610011100
70111710101101
81000810111110
91001911001111
Nibbles 1010 - 1111 are invalid in 8421 BCD
100001 0000A - -
150001 0101F - -
160001 011010 - -
991001 100163 - -
1000001 0000 000064 - -
1270001 0010 01117F - -
2550010 0101 0101FF - -
2560010 0101 0110100 - -
9991001 1001 10013E7 - -
10000001 0000 0000 00003E8 - -
40960100 0000 1001 01101000 - -
99991001 1001 1001 1001270F - -
655350110 0101 0101 0011 0101FFFF - -

Frequently Asked Questions

Nibble values from 1010 (10) through 1111 (15) are undefined in standard 8421 BCD. This converter flags them as invalid and halts the conversion, because interpreting them would produce incorrect decimal digits. Some legacy systems use these codes for sign indicators (e.g., 1100 for positive, 1101 for negative in IBM mainframes), but that is a non-standard extension.
Packed BCD stores two decimal digits per byte (8 bits, two nibbles). Unpacked BCD wastes the upper nibble of each byte, storing one digit per byte (often with the upper nibble zeroed or set to 0011 for ASCII compatibility). This tool accepts raw 4-bit nibbles sequentially, which is equivalent to packed BCD. If your source data is unpacked, strip the upper 4 bits of each byte before entering.
BCD and pure binary are different encodings. For example, decimal 25 in BCD is 0010 0101 (two nibbles: 2 and 5). Interpreted as pure 8-bit binary, 00100101 equals decimal 37, which is hex 25. But the correct BCD interpretation yields decimal 25, which is hex 19. The discrepancy grows with larger values. Always clarify whether your source data is BCD-encoded or raw binary before converting.
JavaScript safely represents integers up to 253 1 (9007199254740991), which is a 16-digit decimal number. This tool uses BigInt internally for values exceeding that threshold, supporting arbitrarily large BCD strings. Practically, inputs up to 64 nibbles (16 bytes of packed BCD) are handled without precision loss.
Yes. Switch the direction toggle to Hex → BCD mode. The converter parses the hex string, converts it to a decimal integer, then encodes each decimal digit as a 4-bit BCD nibble. Note that not every hex value maps to a "round" BCD output. For example, hex FF equals decimal 255, which becomes BCD 0010 0101 0101.
This tool left-pads the input to the nearest 4-bit boundary. If you enter 10101 (5 bits), it becomes 00010101 (8 bits, two nibbles: 1 and 5). Leading zero nibbles are preserved in the breakdown display but do not affect the decimal or hex result. This matches how hardware BCD registers handle alignment.