Binary coded decimal stores each decimal digit as its own four-bit binary code. Instead of converting a complete number to base 2, BCD preserves the number's decimal digit boundaries. Decimal 59, for example, becomes 0101 1001: 0101 represents 5 and 1001 represents 9.
That distinction makes binary coded decimal useful in systems where decimal input, display, or exact decimal behavior matters. This guide explains the standard 8421 BCD code, provides a complete digit table, walks through conversion and addition examples, and shows when ordinary binary is a better choice.
Binary Coded Decimal Table
Standard binary coded decimal is also called 8421 BCD because the four bit positions have weights 8, 4, 2, and 1. Only ten of the sixteen possible four-bit combinations represent decimal digits.
| Decimal digit | Binary coded decimal | 8-bit view |
|---|---|---|
| 0 | 0000 | 00000000 |
| 1 | 0001 | 00000001 |
| 2 | 0010 | 00000010 |
| 3 | 0011 | 00000011 |
| 4 | 0100 | 00000100 |
| 5 | 0101 | 00000101 |
| 6 | 0110 | 00000110 |
| 7 | 0111 | 00000111 |
| 8 | 1000 | 00001000 |
| 9 | 1001 | 00001001 |
The patterns 1010 through 1111 are invalid decimal digits in standard binary coded decimal. Some systems use those six states for signs or other metadata, but they are not decimal values 10 through 15.
The 8-bit column is included only to show leading-zero padding. The essential BCD unit is one four-bit group per decimal digit. For a broader number reference without digit-by-digit encoding, use the binary table from 0 to 100.
BCD Is Not Ordinary Binary
The most important binary coded decimal rule is that each decimal digit is encoded separately. Compare decimal 59:
Decimal digits: 5 9
BCD groups: 0101 1001
BCD result: 01011001
Ordinary binary 59: 0011101101011001 has the ordinary binary value 89, not 59. It represents decimal 59 only when a decoder knows the bits use binary coded decimal. A bit pattern has no inherent notation; its meaning depends on the agreed format.
Ordinary binary is more space-efficient because all bit patterns contribute to one base-2 value. Binary coded decimal spends four bits on every decimal digit and leaves six patterns unused in each group. In return, it keeps decimal digits easy to extract, display, and round.
To review positional base-2 values, read the binary number system guide. You can also use the decimal to binary converter to see ordinary binary and compare it with the digit groups in this article.
How to Convert Decimal to Binary Coded Decimal
Convert a decimal number to binary coded decimal one digit at a time:
- Keep the decimal digits separated.
- Look up each digit's four-bit 8421 code.
- Place the groups in the original left-to-right order.
- Preserve leading decimal zeros when they are meaningful.
Example: Convert 407 to BCD
Separate the digits as 4, 0, and 7:
4 -> 0100
0 -> 0000
7 -> 0111
407 -> 0100 0000 0111The middle 0000 group must remain because it represents the tens digit. Removing it would change the binary coded decimal sequence to 47.
Example: Convert 98.25 to BCD
Encode the digits and retain the decimal point as formatting metadata:
9 -> 1001
8 -> 1000
2 -> 0010
5 -> 0101
98.25 -> 1001 1000 . 0010 0101The point is not one of the four-bit digit codes. A storage format must track its position separately or use an implied scale. For example, a financial field may define the last two binary coded decimal digits as cents.
How to Convert BCD to Decimal
To decode binary coded decimal, divide the bit string into groups of four from the format-defined boundary, validate every group, then translate each group to one decimal digit.
Decode 0011 0110 1001:
0011 -> 3
0110 -> 6
1001 -> 9
Result: 369Do not convert the entire bit string with the ordinary binary to decimal converter; that would interpret it as one base-2 integer. Also reject a group such as 1100, because standard 8421 binary coded decimal has no decimal digit for that code.
Grouping is part of the binary coded decimal format. Packed BCD normally stores two digits per byte, one in each nibble. Unpacked BCD commonly dedicates a whole byte to each digit, placing the code in the lower nibble and zeros or metadata in the upper nibble.
Packed and Unpacked BCD
Packed BCD places two decimal digits in one byte:
Decimal 27 -> 0010 0111
2 7This is the usual compact form of binary coded decimal. Four decimal digits need 16 bits, while an unsigned ordinary binary value up to 9999 needs only 14 bits.
Unpacked binary coded decimal uses one byte per digit:
Decimal 27 -> 00000010 00000111Unpacked BCD wastes more space but can be convenient when a processor, display controller, or legacy protocol handles one decimal digit at a time. Some formats use the upper nibble as a zone or sign field, so the exact specification must be known before decoding.
The word nibble means four bits. Because one binary coded decimal digit occupies one nibble, hexadecimal tools are convenient for inspecting packed data. The file to hex converter can expose raw bytes, but a hex view still needs a format definition before you can decide whether a nibble is BCD, an ordinary integer, text, or something else.
Binary Coded Decimal Addition
Adding binary coded decimal values starts like binary addition, but a digit result may need correction. A four-bit sum is invalid when it exceeds 1001 (decimal 9) or produces a carry out of the nibble. Add 0110 (decimal 6) to the invalid digit result; this skips the six unused states and produces the correct decimal carry.
Example: Add 7 and 5
First add the codes as binary values:
0111 (7)
+ 0101 (5)
------
1100 (invalid BCD digit)Because 1100 is greater than 1001, add the correction value 0110:
1100
+ 0110
------
1 0010The carry 1 becomes the tens digit and 0010 is the ones digit. The binary coded decimal result is 0001 0010, representing decimal 12.
Why the Correction Value Is Six
Four bits contain sixteen patterns, but binary coded decimal uses only ten. There are six invalid states after 9. Adding 6 moves an invalid binary sum into the next decimal digit range while leaving the corrected low nibble at the proper value.
For multi-digit binary coded decimal addition, correct each digit and pass its decimal carry to the next group. Hardware can implement the detection and correction with combinational logic. The logic gates guide explains the gates used to build such arithmetic circuits, while the binary addition calculator shows ordinary base-2 carries without BCD correction.
Signs, Decimal Points, and Leading Zeros
Standard 8421 binary coded decimal defines digits, not a complete signed-number file format. A larger specification must answer several questions:
- Is the sign stored in a separate bit, byte, or final nibble?
- Is the decimal point explicit, or is its position implied by a fixed scale?
- Are leading zeros significant for display or record width?
- Does each byte place the first digit in the high or low nibble?
- Are unused nibble values allowed as sign codes or sentinels?
For example, a packed financial record might store 0010 0101 0110 1100, where the final 1100 means positive in that particular signed BCD convention. That interpretation is not universal. Without the record specification, treating 1100 as a decimal digit would be an error.
In binary coded decimal, leading zeros can be meaningful even when they do not change a mathematical value. A six-digit meter reading of 000127 requires six binary coded decimal groups if the display width must be preserved.
Where Binary Coded Decimal Is Used
Binary coded decimal is valuable when a system interacts closely with decimal conventions:
- Calculators and numeric displays can map stored digit groups directly to display positions.
- Financial systems may prefer exact decimal digits and fixed decimal scales.
- Real-time clocks often expose seconds, minutes, dates, or years in BCD-coded registers.
- Digital meters and counters naturally collect and display decimal digits.
- Legacy business data may use packed decimal formats for compact records.
- Embedded devices sometimes exchange decimal-oriented values through hardware registers or protocols.
The binary coded decimal format does not automatically guarantee correct financial arithmetic. Precision also depends on field width, scale, rounding rules, overflow handling, and the operations implemented by the system. Binary coded decimal simply makes the decimal representation explicit.
Advantages and Disadvantages
Advantages
- Decimal digits can be extracted and displayed without repeated division by ten.
- Values such as
0.1can be represented as exact decimal digits when the scale is defined. - Decimal rounding rules can be easier to implement and audit.
- Each group is independently validated against the range
0000-1001. - Human-facing records retain leading zeros and digit boundaries.
Disadvantages
- Binary coded decimal uses more bits than ordinary binary for most ranges.
- Six of sixteen nibble patterns are unused for digits.
- Arithmetic needs decimal correction logic and may be slower than native binary arithmetic.
- Multiple packed, unpacked, signed, and zoned conventions create interoperability risks.
- A raw bit sequence is easy to misread when its encoding metadata is missing.
For computation-heavy work, ordinary binary usually wins on storage efficiency and hardware support. For decimal-heavy input, output, and exact fixed-scale records, binary coded decimal can reduce conversion and representation problems.
BCD, ASCII, and Hexadecimal Are Different
Binary coded decimal represents a decimal digit by its numeric four-bit value. ASCII represents the character used to write that digit. Hexadecimal is a notation for displaying a bit pattern.
For the decimal digit 7:
| Representation | Bits / value |
|---|---|
| Binary coded decimal digit | 0111 |
ASCII character 7 | 00110111 (0x37) |
| Ordinary binary value 7 | 111 |
Packed binary coded decimal 0010 0111 represents decimal 27, while ASCII text 27 uses bytes 00110010 00110111. The ASCII table shows why text digits have different codes. A hex viewer might display the packed BCD byte as 0x27, but that display does not make the data a hexadecimal number; it is still one byte being interpreted under a BCD format.
Common Mistakes
- Converting the entire BCD bit string as one base-2 number.
- Treating
1010-1111as valid standard BCD digits. - Dropping a
0000group in the middle of a decimal value. - Assuming the location of a decimal point or sign without a format specification.
- Confusing the code for a digit with the ASCII code for its printed character.
- Applying ordinary binary addition without correcting a sum above 9.
- Ignoring whether packed digits begin in the high nibble or low nibble.
Frequently Asked Questions
What does binary coded decimal mean?
Binary coded decimal means that each decimal digit from 0 through 9 is encoded separately as a four-bit binary pattern. The standard 8421 form uses 0000 for 0 through 1001 for 9.
Why is BCD called 8421 code?
The four bit positions have place weights 8, 4, 2, and 1. Adding the weights whose bits are 1 gives the represented decimal digit. For 0101, the active weights are 4 and 1, so the digit is 5.
Is BCD the same as hexadecimal?
No. Hexadecimal uses all sixteen four-bit patterns as digits 0 through F. Standard binary coded decimal uses only the ten patterns for decimal 0 through 9. Hex notation can display BCD bytes, but it does not define their meaning.
Why are six BCD combinations invalid?
A nibble has sixteen possible states, while decimal has ten digits. The six patterns from 1010 to 1111 therefore have no digit meaning in standard 8421 binary coded decimal.
How many bits does a BCD number need?
Each decimal digit needs four bits in packed BCD. A six-digit unsigned value requires 24 bits, plus any separate sign, scale, or metadata required by the storage format.
Is binary coded decimal still used?
Yes. It remains present in decimal displays, real-time clock chips, meters, embedded interfaces, calculators, and legacy packed-decimal business formats. Ordinary binary is more common for general computation.
Summary
Binary coded decimal preserves decimal structure by assigning one four-bit 8421 code to every digit. That makes display and exact decimal handling straightforward, but costs storage and requires correction during arithmetic. Always group bits by digit, validate every nibble, and consult the surrounding specification for signs, decimal points, byte order, and special codes.
