toolery

Decimal to BCD converter

Convert a decimal number to Binary-Coded Decimal by encoding each digit into its own 4-bit binary group, with every digit shown separately.

Each digit, encoded on its own
BCD
—
The same number in plain binary
—

How it works

BCD does not convert a number to binary. It converts each digit to binary, separately, and keeps them in order — so 2026 becomes four independent 4-bit groups rather than one binary number. That is why the two outputs above disagree: as plain binary 2026 is 11111101010, but as BCD it is four groups that still visibly read 2, 0, 2, 6. Four bits can hold sixteen values while a digit only needs ten, so the six patterns from 1010 to 1111 are simply never used — wasteful, and deliberately so. The payoff is that driving a seven-segment display, or printing a number, needs no division at all: each group already is the digit. That trade mattered enough that BCD is still in calculators, digital clocks, and financial systems where decimal rounding has to behave exactly as a person expects.

Used this in a paper or lesson?