1. Home
  2. Developer tools
  3. BCD Converter

BCD Converter

Binary-coded decimal writes each decimal digit as its own four bits, which is how digital clocks, calculators and some financial hardware store numbers. This page encodes and decodes the packed, unpacked and Excess-3 forms.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use BCD Converter

  1. Choose decimal to BCD or BCD to decimal.
  2. Pick packed, unpacked or Excess-3.
  3. Enter the number or the bits and copy the result.

Features

  • Packed BCD (two digits per byte), unpacked BCD and Excess-3
  • Decodes bit strings and reports nibbles above 1001 as invalid
  • Accepts spaces between nibbles
  • Shows each digit beside its four bits
  • Works for long digit strings
  • Hex form of the BCD bytes shown

Supported formats

Input

  • Typed or pasted numbers

You get

  • BCD bits
  • Hex
  • Decimal

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the BCD Converter is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Only the digits 0–9 are encoded; signs and decimal points are not part of the code.
  • Nibbles above 1001 are not valid BCD digits and are reported as errors.

Guide

Binary-coded decimal: packed, unpacked and Excess-3

Binary-coded decimal is the odd one out among number systems: it is not a base but a way of writing decimal digits in bits. Each digit from 0 to 9 gets its own small group of bits, and the groups are placed side by side. A processor can add them with special adjust instructions, and a display driver can show them without any division by ten. This page encodes and decodes the three variants you are most likely to meet.

Packed BCD

In packed BCD two digits share a byte, one in each half. The number 59 becomes 0101 1001: the 5 is 0101 and the 9 is 1001. Read as hexadecimal, that byte is 59, which is why packed BCD is easy to eyeball in a memory dump. Real-time clock chips store seconds, minutes and hours in this form, so a register that reads 0x59 means fifty-nine, not eighty-nine.

Unpacked BCD

Unpacked BCD spends a whole byte on every digit, with the upper four bits normally zero. The digits 2, 0, 2, 6 become 00000010, 00000000, 00000010 and 00000110. It wastes space but it is simple to process one byte at a time, and it is close to the way ASCII digits work, where the character for a digit is the digit’s value plus 0x30.

Excess-3

Excess-3 adds three to each digit before writing it in four bits, so 0 becomes 0011 and 9 becomes 1100. The code is self-complementing: inverting every bit of a digit gives the code for nine minus that digit. That property made subtraction by complement convenient in early hardware. The code table printed on the page shows the 8421 and Excess-3 patterns for all ten digits side by side.

Using the page

Choose a direction, pick the variant, and type a decimal number or paste the bits. The result appears with spaces between groups, without spaces, and as hexadecimal, and a table lists the group assigned to each digit. When decoding, spaces between nibbles are optional. Any group above 1001 is reported, together with its position, because the data is probably not BCD at all, or is a BCD value with a sign nibble that this page does not interpret.

A worked example

The Sample button loads 2026. In packed BCD it becomes 0010 0000 0010 0110, which is the hexadecimal number 2026 and takes two bytes. In unpacked BCD it is 00000010 00000000 00000010 00000110, which takes four. In Excess-3 each digit is raised by three first, giving 0101 0011 0101 1001. Compare that with plain binary, where 2026 is 11111101010 and needs eleven bits: BCD is longer, but each digit is separately readable.

Limits

Only the digits 0 to 9 are coded. There is no handling of a minus sign, a decimal point, or the sign nibbles that some mainframe formats add, and no support for the densely packed decimal scheme used in decimal floating-point. Arithmetic is not performed here; the page converts representations. If you have a plain binary number and want its decimal value, use the binary-to-decimal page, because that reads the bits as a single number, not as digits.

Checked against the current version of the BCD Converter on .

Frequently asked questions

Why would anyone store numbers as BCD when binary is more compact?

Because decimal fractions such as 0.10 stay exact and each digit can be sent straight to a display. Money calculations, digital clocks and meters avoid the rounding that a binary conversion would bring. The price is that a byte holds 0 to 99 and not 0 to 255.

What does BCD 1010 mean?

Nothing. Only the codes 0000 to 1001 stand for digits 0 to 9. The six values 1010 to 1111 are unused in BCD, and some processors use them for signs or flags. The decoder on this page reports them as errors.

Why is BCD of 59 not the same as binary 59?

Binary 59 is 111011. BCD writes the digits separately: 5 is 0101 and 9 is 1001, so packed BCD is 0101 1001, which is hex 59.

What is Excess-3?

A BCD variant where each digit is stored as the digit plus 3, so 0 is 0011 and 9 is 1100. It makes subtraction by complementing easier in old hardware.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.