Unpacked BCD

Thread Starter

rajmak88

Joined Sep 18, 2010
6
packed BCD is basically 2 decimal digits binary encoded into one byte
and in case of unpacked BCD each byte represents just one decimal no....
so where exactly these packed and unpacked BCD nos. find their application???
unpacked BCD unnecessarily occupies extra space in memory...is there any kind of an advantage of using unpacked BCD inspite of such wastage of memory space???
 

bretm

Joined Feb 6, 2012
152
As essential storage, no, but sometimes you have to use one byte per digit, such as when you are converting a number to text. It may also be necessary for interfacing with other software or hardware that used BCD. But those are rare edge cases. Unpacked BCD isn't used very often.
 

Papabravo

Joined Feb 24, 2006
21,225
In the broad scheme of things, BCD packed or unpacked can be used for arbitrary precision calculations. Many computers of the "mainframe" era had specific instructions that worked on BCD. The System 360 had this feature. In financial calculations, in particular, converting to binary, doing the calculation, and converting back created certain problems. Even some microprocessors had instructions that facilitated BCD calculations like the DAA (Decimal Adjust Accumulator) and the conditional jump on the Half-Carry bit in the 8080.
 

atferrari

Joined Jan 6, 2004
4,770
packed BCD is basically 2 decimal digits binary encoded into one byte
and in case of unpacked BCD each byte represents just one decimal no....
so where exactly these packed and unpacked BCD nos. find their application???
unpacked BCD unnecessarily occupies extra space in memory...is there any kind of an advantage of using unpacked BCD inspite of such wastage of memory space???
Packed saves space. I use it to cram info in less RAM. To extract each one you need some (even small) software overhead.

Unpacked, uses the double of RAM. It means faster processing.To use each digit in a certain process you do not need that overhead.

Wastage in this context is not an absolute term. It all depends what use it is destined for and what overheard it encompasses, as above.

Yes, I know, you have software (and micros) able to work with packed BCD. If using these check how they implement the carry / borrow between digits inside the byte.
 
Top