Take 12: the digit 1 becomes 0001 (0×8 + 0×4 + 0×2 + 1×1), the digit 2 becomes 0010, and the whole number is 0001 0010. Decoding is the same walk in reverse — split into groups of four, read each group as a digit, concatenate. There is no division, no place-value arithmetic across group boundaries, and no rounding: the mapping is one decimal digit per nibble, always.
Only ten of the sixteen possible 4-bit patterns are legal: 0000 through 1001 (0–9). The patterns 1010 through 1111 (10–15) have no meaning in 8421 BCD, and this converter flags them with the exact group number instead of guessing — paste 0001 1010 above to see it happen.
| Digit | 8421 BCD | Digit | 8421 BCD |
|---|---|---|---|
| 0 | 0000 | 5 | 0101 |
| 1 | 0001 | 6 | 0110 |
| 2 | 0010 | 7 | 0111 |
| 3 | 0011 | 8 | 1000 |
| 4 | 0100 | 9 | 1001 |
If you are new to reading 0s and 1s in general, how to read binary covers the place-value basics, and what is binary code explains where bytes come from in the first place.