BCD Converter
Convert decimal numbers to binary-coded decimal and back. Packed and unpacked BCD, Excess-3, Aiken 2421 and the signed packed decimal used by COBOL and IBM mainframes, with each digit drawn as its 4 bits.
How to Use
- Choose decimal to BCD or BCD to decimal.
- Pick the code: packed BCD (8421), unpacked, Excess-3, Aiken 2421, or signed packed decimal (COMP-3).
- Type a whole number, or the BCD as hex (0x1984) or binary.
- Read the decimal, the BCD in hex and binary, and its size; the drawing links each digit to its 4 bits.
- Invalid codes, such as the nibble 1010 in packed BCD, are pointed out.
Worked Example
1984 in packed BCD. Write each digit in 4 bits: 1 = 0001, 9 = 1001, 8 = 1000, 4 = 0100. Together: 0001 1001 1000 0100, which as hex is 0x1984, the same digits. Plain binary would be 111 1100 0000 (0x7C0), 11 bits instead of 16: BCD trades space for easy decimal conversion.
1984 in Excess-3. Add 3 to each digit first: 4, 12, 11, 7, giving 0100 1100 1011 0111 = 0x4CB7. In COMP-3 packed decimal, +1984 gets a sign nibble C and a leading 0 to fill whole bytes: 01 98 4C.
The common mistake: reading BCD as binary. A clock chip that returns 0x59 for the seconds means 59, not 89 (5 × 16 + 9). Code that treats BCD registers as ordinary binary shows nonsense times, or fails once the seconds pass 9.
Show Work
Formulas
Decimal Inside a Binary Machine
Many early computers worked in decimal, digit by digit: the IBM 650, 1401 and 1620 all stored numbers as decimal digits, because business data was decimal and conversion was expensive. BCD and its relatives let binary hardware do the same, and the self-complementing Excess-3 and Aiken codes, the latter named after Howard Aiken of the Harvard Mark I, made subtraction by complement simple.
BCD never went away. IBM’s System/360 added packed-decimal instructions in 1964 that mainframes still run for COBOL, Intel’s x86 kept the DAA (decimal adjust) instruction until 64-bit mode removed it, pocket calculators compute in BCD so that 0.1 + 0.2 is exactly 0.3, and IEEE 754-2008 added decimal floating point for the same reason.
About This Calculator
This converter turns whole numbers into packed or unpacked BCD, Excess-3, Aiken 2421 or signed packed decimal (COMP-3), and decodes any of them from hex or binary, reporting invalid nibbles rather than guessing. It shows the code in hex and binary, its size compared with plain binary, and draws each digit linked to its 4 bits.
Everything runs in your browser; nothing is sent anywhere. Numbers of up to 64 digits are supported.
Related calculators: Number Base Converter, Signed Number Representations, and Bit Field Designer.
Frequently Asked Questions
What is BCD?
Binary-coded decimal stores each decimal digit in its own 4 bits, instead of converting the whole number to binary. 1984 becomes 0001 1001 1000 0100, which reads as 0x1984 in hex: the decimal digits are visible in the hex. The patterns 1010 to 1111 are unused.
Why use BCD instead of binary?
Because decimal numbers convert to and from it exactly and cheaply, with no rounding: 0.1 is just a digit. That is why financial software (COBOL’s packed decimal), calculators, digital clocks and the real-time clock chips in PCs use it, and why seven-segment displays take BCD input.
What is the difference between packed and unpacked BCD?
Packed BCD puts two digits in each byte: 1984 is the two bytes 19 84. Unpacked puts one digit per byte, with the high nibble zero: 01 09 08 04. Adding 0x30 to each unpacked byte gives the ASCII digits “1984”.
What are Excess-3 and Aiken code?
Other 4-bit codes for decimal digits. Excess-3 adds 3 to each digit (0 is 0011, 9 is 1100), and Aiken 2421 weights the bits 2, 4, 2, 1. Both are self-complementing: inverting the bits of a digit gives 9 minus that digit, which made subtraction easy in early calculating machines.
How does COMP-3 packed decimal store a sign?
In an extra nibble at the end: C (1100) for positive, D (1101) for negative, F for unsigned. The digits are packed two per byte, with a leading 0 if needed to fill whole bytes. +1984 is 01 98 4C and −1984 is 01 98 4D.
How do I use the BCD Converter?
Simply type or paste your value and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.
Is it free? Does it work without internet?
Yes to both. It is free with no sign-up, and once the page has loaded it keeps working even with no internet.
Where does my data go?
Nowhere — every calculation runs on your own device. Nothing you enter is uploaded, logged, or stored.
Common Use Cases
Digital electronics
1984 in BCD is 0001 1001 1000 0100 for a 4-digit seven-segment display.
Real-time clocks
An RTC register reading 0x59 means 59 seconds, not 89.
Mainframe data
COMP-3 bytes 01 98 4D decode to −1984.
Coursework
1984 in Excess-3 is 0100 1100 1011 0111 (0x4CB7).
Last updated: