Densely packed decimal
   HOME

TheInfoList



OR:

Densely packed decimal (DPD) is an efficient method for binary encoding
decimal The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu–Arabic numeral ...
digits. The traditional system of binary encoding for decimal digits, known as
binary-coded decimal In computing and electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each digit is represented by a fixed number of bits, usually four or eight. Sometimes, special bit patterns are used ...
(BCD), uses four bits to encode each digit, resulting in significant wastage of
binary data Binary data is data whose unit can take on only two possible states. These are often labelled as 0 and 1 in accordance with the binary numeral system and Boolean algebra. Binary data occurs in many different technical and scientific fields, wher ...
bandwidth (since four bits can store 16 states and are being used to store only 10), even when using packed BCD. Densely packed decimal is a more efficient code that packs three digits into ten bits using a scheme that allows compression from, or expansion to, BCD with only two or three hardware gate delays. The densely packed decimal encoding is a refinement of
Chen–Ho encoding Chen–Ho encoding is a memory-efficient alternate system of binary encoding for decimal digits. The traditional system of binary encoding for decimal digits, known as binary-coded decimal (BCD), uses four bits to encode each digit, resulting in ...
; 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 three-digit encoding. This means that arbitrary numbers of decimal digits (not only 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 – that is, 12 sets of three decimal digits can be encoded using 12 sets of ten binary bits and the remaining two decimal digits can be encoded using a further seven binary bits. * The subset encoding mentioned above is simply the rightmost bits of the standard three-digit encoding; the encoded value can be widened simply by adding leading 0 bits. * All seven-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 eight bits for BCD, but the above property requires that the DPD encoding must fit into seven 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 three base-5 digits to seven binary bits. Further, digit-wise
logical value In logic and mathematics, a truth value, sometimes called a logical value, is a value indicating the relation of a proposition to truth, which in classical logic has only two possible values (''true'' or '' false''). Computing In some progra ...
s (in which each digit is either 0 or 1) can be manipulated directly without any encoding or decoding being necessary.


History

In 1969, Theodore M. Hertz, and in 1971, Tien Chi Chen () with Irving Tze Ho () devised lossless prefix codes (referred to as
Hertz The hertz (symbol: Hz) is the unit of frequency in the International System of Units (SI), equivalent to one event (or cycle) per second. The hertz is an SI derived unit whose expression in terms of SI base units is s−1, meaning that o ...
and
Chen–Ho encoding Chen–Ho encoding is a memory-efficient alternate system of binary encoding for decimal digits. The traditional system of binary encoding for decimal digits, known as binary-coded decimal (BCD), uses four bits to encode each digit, resulting in ...
s) which packed three decimal digits into ten 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, devised by Mike F. Cowlishaw in 2002, which was incorporated into the
IEEE 754-2008 The Institute of Electrical and Electronics Engineers (IEEE) is a 501(c)(3) professional association for electronic engineering and electrical engineering (and associated disciplines) with its corporate office in New York City and its operation ...
and ISO/IEC/IEEE 60559:2011 standards for decimal
floating point In computing, floating-point arithmetic (FP) is arithmetic that represents real numbers approximately, using an integer with a fixed precision, called the significand, scaled by an integer exponent of a fixed base. For example, 12.345 can ...
.


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 bits of each of the three digits to be encoded determine one of eight 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 seven bits can be considered a seven-bit encoding for three 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. The eight decimal values whose digits are all 8s or 9s have four codings each. The bits marked x in the table above are ignored on input, but will always be 0 in computed results. (The 3 × 8 = 24 non-standard encodings fill in the gap between 103 = 1000 and 210 = 1024.)


Examples

This table shows some representative decimal numbers and their encodings in BCD, Chen–Ho, and densely packed decimal (DPD):


See also

*
Binary-coded decimal In computing and electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each digit is represented by a fixed number of bits, usually four or eight. Sometimes, special bit patterns are used ...
(BCD) *
Binary integer decimal The IEEE 754-2008 standard includes decimal floating-point number formats in which the significand and the exponent (and the payloads of NaNs) can be encoded in two ways, referred to as binary encoding and ''decimal encoding''. Both formats br ...
(BID) *
decimal32 floating-point format In computing, decimal32 is a decimal floating-point computer numbering format that occupies 4 bytes (32 bits) in computer memory. It is intended for applications where it is necessary to emulate decimal rounding exactly, such as finan ...
*
decimal64 floating-point format In computing, decimal64 is a decimal floating-point computer numbering format that occupies 8 bytes (64 bits) in computer memory. It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and ...
*
decimal128 floating-point format In computing, decimal128 is a decimal floating-point computer numbering format that occupies 16 bytes (128 bits) in computer memory. It is intended for applications where it is necessary to emulate decimal rounding exactly, such as fi ...
* DEC RADIX 50 / MOD40 * IBM SQUOZE


References


Further reading

*

and

https://web.archive.org/web/20180719054809/https://patentimages.storage.googleapis.com/ba/25/b6/b0ad365c086f5f/EP1231716B1.pd

(NB. This patent is about DPD.) * (NB. An older version can be found here
Packed Decimal Encoding IEEE-754r
) * {{cite web , title=Chen–Ho Encoding and Densely Packed Decimal , author-first=John J. G. , author-last=Savard , date=2018 , orig-date=2007 , work=quadibloc , url=http://www.quadibloc.com/comp/cp020301.htm , access-date=2018-07-16 , url-status=live , archive-url=https://web.archive.org/web/20180703002320/http://www.quadibloc.com/comp/cp020301.htm , archive-date=2018-07-03 Binary arithmetic 2002 introductions 2002 in science