BCD (Binary-Coded Decimal) Converter
Convert decimal integers to 8421 BCD format. Visualize nibble separation and understand the bitwise logic used in RTCs and financial systems.
About
Binary-Coded Decimal (BCD) maps specific decimal digits to fixed four-bit binary sequences (nibbles). Unlike pure binary, which converts the entire number's value, BCD encodes each digit independently. This format is critical in financial systems where floating-point errors are unacceptable, and in legacy hardware like Real-Time Clocks (RTC) or 7-segment display drivers.
Efficiency is sacrificed for accuracy and display ease. A standard byte can store values up to 255 in pure binary, but only 99 in packed BCD. This tool focuses on the standard 8421 weighting system, where bits represent 8, 4, 2, and 1 respectively.
Formulas
The BCD value is calculated by isolating each decimal digit d and finding the boolean coefficients b such that:
For example, the digit 5 maps to 0101 because 4 + 1 = 5.
Reference Data
| Decimal | BCD Nibble (8421) | Bit Logic (8+4+2+1) |
|---|---|---|
| 0 | 0000 | 0 + 0 + 0 + 0 |
| 1 | 0001 | 0 + 0 + 0 + 1 |
| 2 | 0010 | 0 + 0 + 2 + 0 |
| 3 | 0011 | 0 + 0 + 2 + 1 |
| 4 | 0100 | 0 + 4 + 0 + 0 |
| 5 | 0101 | 0 + 4 + 0 + 1 |
| 6 | 0110 | 0 + 4 + 2 + 0 |
| 7 | 0111 | 0 + 4 + 2 + 1 |
| 8 | 1000 | 8 + 0 + 0 + 0 |
| 9 | 1001 | 8 + 0 + 0 + 1 |