What Is BCD Encoding and Why Did Old Computers Use It?

BCD encoding — Chunky Munster

BCD encoding is a way to store decimal digits one at a time using binary patterns. Old computers used it when they needed to keep numbers aligned with how humans read, print, and enter them, especially in finance, calculators, and digital clocks. If you want to inspect the format directly, try our free BCD converter.

What BCD encoding actually stores

BCD stands for binary-coded decimal. The key idea is simple: each decimal digit gets its own 4-bit binary value, usually in the common 8421 layout.

That means the digits are stored individually instead of being merged into one pure binary number. For example, decimal 45 becomes 0100 0101 in packed BCD, because 4 maps to 0100 and 5 maps to 0101.

That is different from regular binary, where 45 is stored as 101101. Both represent the same value when decoded correctly, but they are not the same representation and they do not behave the same way in hardware.

The tradeoff is obvious: BCD wastes space compared with binary. The benefit is that each decimal digit stays visible and separate, which makes some kinds of processing much easier.

Why old computers used it

Older hardware was built under tighter constraints than most modern systems. Transistors were expensive, memory was tiny, and floating-point hardware was not always available. BCD gave engineers a cheap way to handle decimal values without having to wrestle with awkward binary-to-decimal conversions all the time.

This mattered in machines that displayed numbers to humans. If a cash register, calculator, or bank terminal needs to show 199.95, decimal-digit storage is convenient because every digit already exists in a form that can be printed, scanned, or encoded for a display.

BCD also reduced rounding weirdness in some business applications. Binary fractions can represent values like 0.1 only approximately, which is fine for many tasks and a headache for others. Decimal digit storage was often the safer choice when exact cents mattered more than raw math speed.

That said, BCD was never a magic fix. Arithmetic with BCD often requires correction steps after addition or subtraction, so the hardware gets a little more complicated even if the representation is human-friendly.

Packed BCD, unpacked BCD, and variants

There is more than one way to use BCD. The two common forms you will see are packed BCD and unpacked BCD.

Packed BCD is more space-efficient, which is why it showed up in storage and transmission formats. Unpacked BCD is easier to debug in some old systems because each byte maps cleanly to one visible digit.

There are also format quirks in different machines and file formats. Some use a sign nibble at the end of the number, some reserve particular nibble values for separators or control purposes, and some use zoned decimal variants instead of what most people mean by “BCD.”

In practice, when someone says BCD encoding, they usually mean digit-by-digit decimal storage in 4-bit chunks. The exact rules depend on the system, so it is worth checking the format before decoding real data.

How BCD arithmetic works in hardware

BCD is not just a storage trick. Old processors and calculators often did arithmetic directly in decimal digits, or they did binary math and then corrected the result back into BCD form.

Here is the rough problem: adding two 4-bit digit values can produce numbers larger than 9. In plain binary, that is fine. In BCD, any nibble above 1001 is invalid as a decimal digit and needs correction.

A classic rule is to add 6 after a nibble overflows past 9. That pushes the result into the next valid BCD digit range and carries the extra value into the next nibble.

7 + 8 = 15 decimal
0111 + 1000 = 1111  (invalid BCD digit)
1111 + 0110 = 1 0101

After the correction, the lower nibble becomes 0101 (5) and the carry becomes 1, which gives the correct decimal result of 15. That little +6 fix is one of the reasons BCD hardware looked a bit odd compared with pure binary arithmetic units.

This is also why BCD can be slower in software. Modern CPUs are optimized for binary math first, so if you are repeatedly adding or multiplying BCD values, you often end up doing extra work.

Where BCD still shows up

BCD is old, but it is not extinct. You still encounter it in legacy mainframes, financial systems, embedded devices, digital meters, and some communication protocols that prefer decimal digits over binary integers.

It also appears in date fields, display controllers, and low-level hardware documentation. If a spec says a value is stored as 0x45 meaning decimal 45, that is a clue you are dealing with a decimal-digit format rather than a normal binary integer.

That makes BCD especially relevant when you are reading old file formats or reverse-engineering a device. A number that looks wrong in binary may make perfect sense once you split it into nibbles and read each nibble as a decimal digit.

For a broader refresher on how decimal values compare with other bases, see our guide on converting between binary, octal, decimal, and hexadecimal.

Why BCD fell out of the mainstream

Once general-purpose CPUs got faster and memory became cheaper, BCD lost most of its advantages. Pure binary is smaller, simpler to compute with, and better supported by modern hardware.

Decimal output is still easy to generate from binary integers when you need it. The CPU can do the heavy lifting in binary, and software can format the result as human-readable decimal at the end. That split is usually cleaner than storing everything as BCD from the start.

There is also a standards issue. Binary integers are widely understood across programming languages, architectures, and data formats. BCD remains useful in niches, but it no longer has to carry the weight of general computing.

So BCD did not disappear because it was broken. It faded because better tools showed up for most jobs.

A Worked Example

Suppose you need to store the decimal number 2749 in packed BCD. You split the number into digits and encode each one separately.

Decimal digits: 2 7 4 9
BCD nibbles:    0010 0111 0100 1001
Packed bytes:    0x27 0x49

Now compare that with normal binary storage. The same decimal value as a binary integer is 101010111101.

Decimal: 2749
Binary : 101010111101
BCD    : 0010 0111 0100 1001

If you are debugging a hex dump, this difference matters a lot. Seeing 0x27 0x49 might mean the value 2749, not the binary integer 10057. The only way to know is to check the encoding rule.

Here is a tiny decoder sketch in JavaScript for packed BCD:

function decodePackedBcd(bytes) {
  return [...bytes].map(byte => {
    const hi = (byte >> 4) & 0x0f;
    const lo = byte & 0x0f;
    return String(hi) + String(lo);
  }).join('');
}

console.log(decodePackedBcd([0x27, 0x49])); // "2749"

This is the sort of thing you use when you are reading a device protocol, a legacy database field, or a dump from old hardware.

Frequently Asked Questions

Is BCD the same as binary?

No. Binary stores the whole number in base 2, while BCD stores each decimal digit separately as a 4-bit value. Both can represent the same number, but the layout and arithmetic rules are different.

Why is BCD inefficient?

BCD uses 4 bits to store a digit that only needs values 0 through 9, so some bit patterns are wasted. Packed BCD also needs extra correction logic for arithmetic, which adds overhead compared with normal binary integers.

Where is BCD used today?

You still see BCD in legacy financial systems, calculators, embedded devices, and some hardware protocols. It is also common in situations where decimal digits must be preserved exactly for display or interchange.

How do I convert a number to BCD?

Split the number into decimal digits, then convert each digit to a 4-bit binary nibble. For example, 507 becomes 0101 0000 0111 in BCD. If you want to check your result quickly, use a converter instead of doing the nibble math by hand.

The Bottom Line

BCD encoding exists because some machines needed decimal numbers to stay human-shaped all the way through storage and arithmetic. That made older calculators, terminals, and business systems easier to build and debug, even if the format was less efficient than binary.

Today, BCD mostly turns up in legacy systems and hardware corners where decimal precision or compatibility still matters. If you are staring at a byte dump and a number looks suspiciously off, split it into nibbles and see whether it is really BCD before you blame the data.

When you want to test a value or decode a packed byte sequence, use the BCD converter and save yourself some nibble-counting.

// try the tool
try our free BCD converter →
// related reading
← all posts