Densely Packed Decimal
Encyclopedia
Densely packed decimal is a system of binary encoding for decimal
Decimal
The decimal numeral system has ten as its base. It is the numerical base most widely used by modern civilizations....

 digits.

The traditional system of binary encoding for decimal digits, known as Binary-coded decimal
Binary-coded decimal
In computing and electronic systems, binary-coded decimal is a digital encoding method for numbers using decimal notation, with each decimal digit represented by its own binary sequence. In BCD, a numeral is usually represented by four bits which, in general, represent the decimal range 0 through 9...

 (BCD), uses four bits to encode each digit, resulting in significant wastage of binary data bandwidth (since four bits can store 16 states and are being used to store only 10). Densely Packed Decimal is a more efficient code that packs three digits into 10 bits using a scheme that allows compression from, or expansion to, BCD with only two or three gate delays in hardware.

The densely packed decimal encoding is a refinement of Chen-Ho encoding
Chen-Ho encoding
Chen-Ho encoding is an alternate system of binary encoding for decimal digits.The traditional system of binary encoding for decimal digits, known as Binary-coded decimal , uses four bits to encode each digit, resulting in significant wastage of binary data bandwidth .The concepts behind Chen-Ho...

; it gives the same compression and speed advantages, but the particular arrangement of bits used confers additional advantages:
  • Compression of one or two digits (into the optimal four or seven bits respectively) is achieved as a subset of the 3-digit encoding. This means that arbitrary numbers of decimal digits (not just multiples of three digits) can be encoded efficiently. For example, 38=12×3+2 decimal digits can be encoded in 12×10+7=127 bits.

  • The subset encoding mentioned above is simply the rightmost bits of the standard 3-digit encoding; the encoded value can be widened simply by adding leading 0 bits.

  • All 7-bit BCD numbers (0 through 79) are encoded identically by DPD. This makes conversions of common small numbers trivial. (This must break down at 80, because that requires 8 bits for BCD, but the above property requires that the DPD encoding must fit into 7 bits.)

  • The low-order bit of each digit is copied unmodified. Thus, the non-trivial portion of the encoding can be considered a conversion from 3 base-5 digits to 7 binary bits. Further, digit-wise logical values (in which each digit is either 0 or 1) can be manipulated directly without any encoding or decoding being necessary.

History

In 1971, Tien Chi Chen and Dr. Irving T. Ho devised a lossless prefix code
Prefix code
A prefix code is a type of code system distinguished by its possession of the "prefix property"; which states that there is no valid code word in the system that is a prefix of any other valid code word in the set...

 (now known as Chen-Ho encoding
Chen-Ho encoding
Chen-Ho encoding is an alternate system of binary encoding for decimal digits.The traditional system of binary encoding for decimal digits, known as Binary-coded decimal , uses four bits to encode each digit, resulting in significant wastage of binary data bandwidth .The concepts behind Chen-Ho...

) which packed three decimal digits into 10 binary bits using a scheme which allowed compression from or expansion to BCD with only two or three gate delays in hardware. Densely Packed Decimal is a refinement of this, by Mike Cowlishaw
Mike Cowlishaw
Mike Cowlishaw is a retired IBM Fellow, a Visiting Professor at the Department of Computer Science at the University of Warwick, and is a Fellow of the Royal Academy of Engineering , the Institute of Engineering and Technology , and the British Computer Society.- Career at IBM :Cowlishaw joined IBM...

, which was incorporated into the IEEE 754-2008 standard for decimal floating-point.

Encoding

Like Chen-Ho encoding, DPD encoding classifies each decimal digit into one of two ranges, depending on the most significant bit of the binary form: "small" digits have values 0 through 7 (binary 0000–0111), and "large" digits, 8 through 9 (binary 1000–1001). Once it is known or has been indicated that a digit is small, three more bits are still required to specify the value. If a large value has been indicated, only one bit is required to distinguish between the values 8 or 9.

When encoding, the most significant bit of each of the three digits to be encoded select one of 8 coding patterns for the remaining bits, according to the following table. The table shows how, on decoding, the ten bits of the coded form in columns b9 through b0 are copied into the three digits d2 through d0, and the remaining bits are filled in with constant zeros or ones.
Bits b7, b4 and b0 (c, f and i) are passed through the encoding unchanged, and do not affect the meaning of the other bits. The remaining 7 bits can be considered a 7-bit encoding for 3 base-5 digits.

Bits b8 and b9 are not needed and ignored when decoding DPD groups with three large digits (marked as "x" in the last row of the table above), but are filled with zeros when encoding.

Examples

This table shows some representative decimal numbers and their
encodings in BCD, Chen-Ho, and Densely Packed Decimal (DPD):
Decimal BCD Chen-Ho DPD
005 0000 0000 0101 000 000 0101 000 000 0101
009 0000 0000 1001 110 000 0001 000 000 1001
055 0000 0101 0101 000 010 1101 000 101 0101
079 0000 0111 1001 110 011 1001 000 111 1001
080 0000 1000 0000 101 000 0000 000 000 1010
099 0000 1001 1001 111 000 1001 000 101 1111
555 0101 0101 0101 010 110 1101 101 101 0101
999 1001 1001 1001 111 111 1001 001 111 1111

See also

  • decimal32 floating-point format
    Decimal32 floating-point format
    In computing, decimal32 is a decimal floating-point computer numbering format that occupies 4 bytes in computer memory.It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations....

  • decimal64 floating-point format
    Decimal64 floating-point format
    In computing, decimal64 is a decimal floating-point computer numbering format that occupies 8 bytes in computer memory.It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations....

  • decimal128 floating-point format
    Decimal128 floating-point format
    In computing, decimal128 is a decimal floating-point computer numbering format that occupies 16 bytes in computer memory.It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations.Decimal128 supports 34 decimal digits of...

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK