InfyCalculator
💻

BCD Converter (Decimal to BCD)

Convert decimal numbers to binary-coded decimal (8421 BCD) and Excess-3, digit by digit, compare with pure binary, or decode a BCD bit string back to decimal and catch invalid nibbles.

Direction
Value
Loading calculator…

How it works

BCD: each decimal digit → its own 4-bit group with weights 8-4-2-1 (0 = 0000 … 9 = 1001; 1010–1111 unused) · Excess-3: digit + 3 in 4 bits · packed BCD: two digits per byte, so the hex view reads like the decimal number

Binary-coded decimal stores every decimal digit separately in four bits instead of converting the whole number to binary. It wastes some space (16 BCD bits hold 0–9,999, while 16 binary bits reach 65,535) but makes decimal display, rounding and money arithmetic exact and simple — which is why it appears in seven-segment drivers, real-time clocks, financial hardware and COBOL packed decimals. Excess-3 is a self-complementing variant used in older decimal adders.

Worked example

2026 → 2 = 0010, 0 = 0000, 2 = 0010, 6 = 0110, so the BCD code is 0010 0000 0010 0110 (16 bits). In Excess-3 each digit is shifted by 3: 0101 0011 0101 1001. The pure binary value is 111 1110 1010 — only 11 bits — and the packed BCD bytes read 0x2026 in hex.

Sources: Binary-coded decimal — Wikipedia · Excess-3 — Wikipedia

Frequently asked questions

What is the difference between BCD and binary?

Binary converts the whole number at once (2026 = 11111101010). BCD converts digit by digit (2026 = 0010 0000 0010 0110). BCD needs more bits but each group maps directly to one decimal digit.

Why are 1010 to 1111 invalid in BCD?

Four bits can hold 0–15, but a decimal digit only goes to 9, so the six patterns 1010–1111 never occur in valid BCD. The decoder flags them; in BCD addition they are what triggers the “add 6” correction.

What is packed versus unpacked BCD?

Packed BCD puts two digits in one byte (0x20 0x26 for 2026); unpacked BCD uses a whole byte per digit with the upper nibble zero (or 0011 for ASCII digits). The calculator shows the packed form as hex.

What is Excess-3 code used for?

Excess-3 adds 3 to each digit before encoding. Its 9’s complement is obtained just by inverting the bits, which simplified subtraction in early decimal computers and calculators.

Related calculators

This calculator is for educational purposes. Double-check important results before acting on them.