Packed versus unpacked BCD for 259
exam standardtwo digits per byte, or one
Answer
000000100000010100001001
Why this example is worth doing
Packed BCD stores two digits per byte; unpacked stores one digit per byte with the high nibble unused or set to a fixed value. The page shows both for the same number and explains the trade: unpacked wastes twice the space but converts to ASCII digits by adding 48, so it is what you use immediately before display. This is the same 48 that appears on the binary-to-text page.
Try your own input in the BCD converter. Pack and unpack binary-coded decimal, and add with the +6 correction shown.
How the answer is reached
259 in unpacked BCD
Each decimal digit becomes its own 8-bit group with weights 8-4-2-1. The six patterns 1010..1111 are never produced.
| digit | 8421 code | placement |
|---|---|---|
| 2 | 0010 | low nibble, high nibble zero |
| 5 | 0101 | low nibble, high nibble zero |
| 9 | 1001 | low nibble, high nibble zero |
unpacked BCD0000 0010 0000 0101 0000 1001
compare with plain binary100000011— BCD is longer: it trades density for digit-by-digit decimal arithmetic