An efficient alternate system of binary encoding for decimal digits
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 significant wastage of binary data bandwidth (since four bits can store 16 states and are being used to store only 10),[1] even when using packed BCD.
The encoding reduces the storage requirements of two decimal digits (100 states) from 8 to 7 bits, and those of three decimal digits (1000 states) from 12 to 10 bits using only simple Boolean transformations avoiding any complex arithmetic operations like a base conversion.
History
In what appears to have been a multiple discovery, some of the concepts behind what later became known as Chen–Ho encoding were independently developed by Theodore M. Hertz in 1969[2] and by Tien Chi Chen (陳天機) (1928–)[3][4][5][6] in 1971.
Hertz of Rockwell filed a patent for his encoding in 1969, which was granted in 1971.[2]
Chen first discussed his ideas with Irving Tze Ho (何宜慈) (1921–2003)[7][8][9][10] in 1971. Chen and Ho were both working for IBM at the time, albeit in different locations.[11][12] Chen also consulted with Frank Chin Tung[13] to verify the results of his theories independently.[12] IBM filed a patent in their name in 1973, which was granted in 1974.[14] At least by 1973, Hertz's earlier work must have been known to them, as the patent cites his patent as prior art.[14]
With input from Joseph D. Rutledge and John C. McPherson,[15] the final version of the Chen–Ho encoding was circulated inside IBM in 1974[16] and published in 1975 in the journal Communications of the ACM.[15][17] This version included several refinements, primarily related to the application of the encoding system. It constitutes a Huffman-like prefix code.
The encoding was referred to as Chen and Ho's scheme in 1975,[18]Chen's encoding in 1982[19] and became known as Chen–Ho encoding or Chen–Ho algorithm since 2000.[17] After having filed a patent for it in 2001,[20]Michael F. Cowlishaw published a further refinement of Chen–Ho encoding known as densely packed decimal (DPD) encoding in IEE Proceedings – Computers and Digital Techniques in 2002.[21][22] DPD has subsequently been adopted as the decimal encoding used in the IEEE 754-2008 and ISO/IEC/IEEE 60559:2011floating-point standards.
Application
Chen noted that the digits zero through seven were simply encoded using three binary digits of the corresponding octal group. He also postulated that one could use a flag to identify a different encoding for the digits eight and nine, which would be encoded using a single bit.
In practice, a series of Boolean transformations are applied to the stream of input bits, compressing BCD encoded digits from 12 bits per three digits to 10 bits per three digits. Reversed transformations are used to decode the resulting coded stream to BCD. Equivalent results can also be achieved by the use of a look-up table.
Chen–Ho encoding is limited to encoding sets of three decimal digits into groups of 10 bits (so called declets).[1] Of the 1024 states possible by using 10 bits, it leaves only 24 states unused[1] (with don't care bits typically set to 0 on write and ignored on read). With only 2.34% wastage it gives a 20% more efficient encoding than BCD with one digit in 4 bits.[12][17]
Both, Hertz and Chen also proposed similar, but less efficient, encoding schemes to compress sets of two decimal digits (requiring 8 bits in BCD) into groups of 7 bits.[2][12]
Larger sets of decimal digits could be divided into three- and two-digit groups.[2]
One prominent application uses a 128-bit register to store 33 decimal digits with a three digit exponent, effectively not less than what could be achieved using binary encoding (whereas BCD encoding would need 144 bits to store the same number of digits).
Encodings for two decimal digits
Hertz encoding
Hertz decimal data encoding for a single heptad (1969 form)[2]
^Some 4-bit decimal codes are particularly well suited as alternatives to the 8-4-2-1 BCD code: Jump-at-8 code uses the same values for the ordered states 0 to 7, whereas in the Gray BCD and Glixon codes the values for the states 0 to 7 are still from the same set, but ordered differently (which, however, is transparent for the Hertz, Chen–Ho or densely packed decimal (DPD) encodings, as they pass through the bits unaltered). In these four codes, the most-significant bit can be used as a flag denoting "large" values. For the two "large" values, all but one bits remain static (the two middle bits are always zero for 8-4-2-1 and one for Jump-at-8 code, whilst for Gray BCD code one bit is set and the other cleared, whereas for Glixon code the two lower bits are always zero and one bit inverted, thus the two "large" values being transparently swapped), requiring only minor adaptations in the encoding. Three other codes can be conveniently split into groups of eight and two states as well, containing values from two ranges of consecutive bit patterns. In the case of the and Excess-6 BCD and Jump-at-2 codes, the most-significant bit can still be used to distinguish between the two groups, however, compared to the Jump-at-8 code, the group of small values now contains only two states and the larger group contains the eight larger values. In the case of the O'Brien type-I and Gray–Stibitz code, the next-most significant bit can serve as a flag bit instead, with the remaining bits again forming two groups of consecutive values. Therefore, these differences remain transparent for the encoding.
^Wong, Andrew W. F. (2014-08-15) [2014-07-04, 2014-06-23, 2013-09-16, 2007-07-16, 2007-06-07, 2007-06-04, 2007-05-20, 2007-02-16]. 陳天機 Chen Tien Chi: 如夢令 Ru Meng Ling (As If Dreaming). Classical Chinese Poems in English (in Chinese and English). Translated by Hongfa (宏發), Huang (黃). Archived from the original on 2020-06-25. Retrieved 2020-06-25.
^Chen, Tien Chi (1971-03-12). Decimal-binary integer conversion scheme (Internal memo to Irving Tze Ho). IBM San Jose Research Laboratory, San Jose, California, USA: IBM.
^ abcdefghijChen, Tien Chi (1971-03-29). Decimal Number Compression(PDF) (Internal memo to Irving Tze Ho). IBM San Jose Research Laboratory, San Jose, California, USA: IBM. pp. 1–4. Archived(PDF) from the original on 2012-10-17. Retrieved 2016-02-07. (4 pages)
^Chen, Tien Chi; Ho, Irving Tze (1974-06-25). "Storage-Efficient Representation of Decimal Data". Research Report RJ 1420 (Technical report). IBM San Jose Research Laboratory, San Jose, California, USA: IBM.