Computing

Binary-Coded Decimal (BCD) With Worked Examples

Binary-coded decimal stores each decimal digit in its own 4 bits. 8421 BCD vs plain binary, invalid codes, a real-time clock register and a converter.

Binary-coded decimal (BCD) stores a number one decimal digit at a time, with each digit in its own 4 bits. In the common 8421 form, 59 is 0101 1001: 0101 for the 5 and 1001 for the 9. Plain binary would store 59 as 111011.

Try itType a whole number to compare its BCD and plain binary forms.
BCD
0101 1001
Plain binary
111011
Bits used
BCD 8 vs binary 6
Digit8421 BCD nibble
50101
91001

How 8421 BCD works

The name lists the weights of the four bits in each digit: 8, 4, 2, 1. Each decimal digit 0–9 gets its usual 4-bit binary pattern, and the digits are simply placed side by side.

Decimal digitBCDDecimal digitBCD
0000050101
1000160110
2001070111
3001181000
4010091001

So 2026 in BCD is 0010 0000 0010 0110. Reading it back needs no arithmetic: split into groups of four and read each group as a digit.

BCD vs plain binary

DecimalBCDPlain binaryBits (BCD vs binary)
9100110014 vs 4
100001 000010108 vs 4
590101 10011110118 vs 6
991001 100111000118 vs 7
2550010 0101 01011111111112 vs 8
20260010 0000 0010 01101111110101016 vs 11

BCD uses more bits, because six of the sixteen 4-bit patterns are never used. In exchange, converting to and from human-readable digits is trivial.

Invalid codes: 1010 to 1111

The patterns 1010 through 1111 (10–15) are not valid 8421 BCD digits. A decoder must reject them, which is what the calculator on this page does: 1010 is “not a valid BCD digit”. When BCD addition produces one of these patterns, or carries out of a digit, hardware adds 6 (0110) to skip the unused codes. For example, 8 + 5 in BCD: 1000 + 0101 = 1101 (invalid), and 1101 + 0110 = 1 0011, which is BCD for 13.

Where BCD is used

Real-time clock chips. Texas Instruments’ bq32000 RTC keeps the time in BCD registers: its seconds register holds the tens of seconds in one field and the units in another. A seconds register reading 0x59 therefore means 59 seconds, not 89. Reading these registers as plain binary is a classic firmware bug.

Seven-segment displays. Each digit of a display needs its own value 0–9, and BCD hands it over directly, so display driver chips accept BCD input.

Financial and decimal arithmetic. Decimal fractions such as 0.1 have no exact binary representation, so systems that must round like a person would (money, tax) use decimal arithmetic. Some mainframe processors store this as packed decimal, two BCD digits per byte; in software, Python’s decimal module serves the same purpose.

Packed vs unpacked BCD

Packed BCD puts two digits in one byte (0x59 for 59). Unpacked BCD uses a whole byte per digit, with the digit in the low four bits (0x05 0x09). ASCII digits are close relatives of unpacked BCD: “5” is 0x35, and its low nibble is the digit itself.

For plain binary conversions, the step-by-step solver multiplies each bit by its power of 2. The decimal place-value chart explains the base-10 side of BCD.

Sources

  1. bq32000 Real-Time Clock (RTC) datasheet, Rev. F — Texas Instruments. seconds register stores tens and units of seconds in BCD
  2. decimal — Decimal fixed point and floating point arithmetic — Python documentation

How we made this

Computed and checked by tests. BCD encodings come from src/lib/calc/bcd.js (tested: 2026 → 0010 0000 0010 0110; 1001 0101 → 95; 1010 rejected). The real-time clock example is taken from the register description in TI's bq32000 datasheet, which we read for this article.

Performed by Claude, an AI assistant working in the BinConvert repository (Node.js 25 test runner), November 16, 2026.

This article was drafted with AI assistance. Every example, calculation and command output on this page was re-run or checked before release; every BCD and binary pattern was regenerated and compared. Review: automated test suite and source check, November 16, 2026.

Spotted an error? Tell us and we will correct it.

Copied to clipboard!