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 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, although 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:2011 floating-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 0.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 by divided into three- and two-digit groups.[2]

The patents also discuss the possibility to adapt the scheme to digits encoded in any other decimal codes than 8-4-2-1 BCD,[2] like f.e. Excess-3,[2] Excess-6, Jump-at-2, Jump-at-8, Gray, Glixon, O'Brien type-I and Gray–Stibitz code.[lower-alpha 1] The same principles could also be applied to other bases.

In 1973, some form of Chen–Ho encoding appears to have been utilized in the address conversion hardware of the optional IBM 7070/7074 emulation feature for the IBM System/370 Model 165 and 370 Model 168 computers.[23][24]

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]
Binary encoding Decimal digits
Code space (128 states)b6b5 b4b3b2b1b0 d1d0 Values encoded Description Occurrences (100 states)
50% (64 states)0abcdef 0abc0def(0–7) (0–7)Two lower digits64% (64 states)
12.5% (16 states)110cdef 100c0def(8–9) (0–7)One lower digit,
one higher digit
16% (16 states)
12.5% (16 states)101fabc 0abc100f(0–7) (8–9)16% (16 states)
12.5% (16 states, 4 used)111cxxf 100c100f(8–9) (8–9)Two higher digits4% (4 states)
12.5% (16 states, 0 used)100xxxx 0% (0 states)
  • This encoding is not parity-preserving.

Early Chen–Ho encoding, method A

Decimal data encoding for a single heptad (early 1971 form, method A)[12]
Binary encoding Decimal digits
Code space (128 states)b6b5 b4b3b2b1b0 d1d0 Values encoded Description Occurrences (100 states)
50% (64 states)0abcdef 0abc0def(0–7) (0–7)Two lower digits64% (64 states)
25% (32 states, 16 used)10x[12] (b)[15]cdef 100c0def(8–9) (0–7)One lower digit,
one higher digit
16% (16 states)
12.5% (16 states)110fabc 0abc100f(0–7) (8–9)16% (16 states)
12.5% (16 states, 4 used)111cx[12] (a)[15]x[12] (b)[15]f 100c100f(8–9) (8–9)Two higher digits4% (4 states)
  • This encoding is not parity-preserving.

Early Chen–Ho encoding, method B

Decimal data encoding for a single heptad (early 1971 form, method B)[12]
Binary encoding Decimal digits
Code space (128 states)b6b5 b4b3b2b1b0 d1d0 Values encoded Description Occurrences (100 states)
50% (64 states)0abcdef 0abc0def(0–7) (0–7)Two lower digits64% (64 states)
12.5% (16 states)10c0def 100c0def(8–9) (0–7)One lower digit,
one higher digit
16% (16 states)
12.5% (16 states, 4 used)10c1xxf 100c100f(8–9) (8–9)Two higher digits4% (4 states)
12.5% (16 states)11f0abc 0abc100f(0–7) (8–9)One lower digit,
one higher digit
16% (16 states)
12.5% (16 states, 0 used)11x1xxx 0% (0 states)
  • This encoding is not parity-preserving.

Patented and final Chen–Ho encoding

Decimal data encoding for a single heptad (patented 1973 form[14] and final 1975 form[15])
Binary encoding Decimal digits
Code space (128 states)b6b5 b4b3b2b1b0 d1d0 Values encoded Description Occurrences (100 states)
50% (64 states)0abcdef 0abc0def(0–7) (0–7)Two lower digits64% (64 states)
25.0% (32 states, 16 used)10x[14] (b)[15]cdef 100c0def(8–9) (0–7)One lower digit,
one higher digit
16% (16 states)
12.5% (16 states)111cabf 0abc100f(0–7) (8–9)16% (16 states)
12.5% (16 states, 4 used)110cx[14] (a)[15]x[14] (b)[15]f 100c100f(8–9) (8–9)Two higher digits4% (4 states)

Encodings for three decimal digits

Hertz encoding

Hertz decimal data encoding for a single declet (1969 form)[2]
Binary encoding Decimal digits
Code space (1024 states)b9b8b7b6b5 b4b3b2b1b0 d2d1d0 Values encoded Description Occurrences (1000 states)
50.0% (512 states)0abcdefghi 0abc0def0ghi(0–7) (0–7) (0–7)Three lower digits51.2% (512 states)
37.5% (384 states)100cdefghi 100c0def0ghi(8–9) (0–7) (0–7)Two lower digits,
one higher digit
38.4% (384 states)
101fabcghi 0abc100f0ghi(0–7) (8–9) (0–7)
110iabc def 0abc0def100i(0–7) (0–7) (8–9)
9.375% (96 states)111f00iabc 0abc100f100i(0–7) (8–9) (8–9)One lower digit,
two higher digits
9.6% (96 states)
111c01idef 100c0def100i(8–9) (0–7) (8–9)
111c10fghi100c100f0ghi(8–9) (8–9) (0–7)
3.125% (32 states, 8 used)111c11f(0)(0)i 100c100f100i(8–9) (8–9) (8–9)Three higher digits, bits b2 and b1 are don't care0.8% (8 states)
  • This encoding is not parity-preserving.

Early Chen–Ho encoding

Decimal data encoding for a single declet (early 1971 form)[12]
Binary encoding Decimal digits
Code space (1024 states)b9b8b7b6b5 b4b3b2b1b0 d2d1d0 Values encoded Description Occurrences (1000 states)
50.0% (512 states)0abcdefghi 0abc0def0ghi(0–7) (0–7) (0–7)Three lower digits51.2% (512 states)
37.5% (384 states)100cdefghi 100c0def0ghi(8–9) (0–7) (0–7)Two lower digits,
one higher digit
38.4% (384 states)
101fghiabc 0abc100f0ghi(0–7) (8–9) (0–7)
110iabcdef 0abc0def100i(0–7) (0–7) (8–9)
9.375% (96 states)11100fiabc 0abc100f100i(0–7) (8–9) (8–9)One lower digit,
two higher digits
9.6% (96 states)
11101icdef 100c0def100i(8–9) (0–7) (8–9)
11110cfghi100c100f0ghi(8–9) (8–9) (0–7)
3.125% (32 states, 8 used)11111cfi(0)(0) 100c100f100i(8–9) (8–9) (8–9)Three higher digits, bits b1 and b0 are don't care0.8% (8 states)
  • This encoding is not parity-preserving.

Patented Chen–Ho encoding

Decimal data encoding for a single declet (patented 1973 form)[14]
Binary encoding Decimal digits
Code space (1024 states)b9b8b7b6b5 b4b3b2b1b0 d2d1d0 Values encoded Description Occurrences (1000 states)
50.0% (512 states)0abdeghcfi 0abc0def0ghi(0–7) (0–7) (0–7)Three lower digits51.2% (512 states)
37.5% (384 states)100deghcfi 100c0def0ghi(8–9) (0–7) (0–7)Two lower digits,
one higher digit
38.4% (384 states)
101abghcfi 0abc100f0ghi(0–7) (8–9) (0–7)
110deabcfi 0abc0def100i(0–7) (0–7) (8–9)
9.375% (96 states)11110abcfi 0abc100f100i(0–7) (8–9) (8–9)One lower digit,
two higher digits
9.6% (96 states)
11101decfi 100c0def100i(8–9) (0–7) (8–9)
11100ghcfi 100c100f0ghi(8–9) (8–9) (0–7)
3.125% (32 states, 8 used)11111(0)(0)cfi 100c100f100i(8–9) (8–9) (8–9)Three higher digits, bits b4 and b3 are don't care0.8% (8 states)
  • This encoding is not parity-preserving.[14]

Final Chen–Ho encoding

Chen-Ho decimal data encoding for a single declet (final 1975 form)[15][17]
Binary encoding Decimal digits
Code space (1024 states)b9b8b7b6b5 b4b3b2b1b0 d2d1d0 Values encoded Description Occurrences (1000 states)
50.0% (512 states)0abcdefghi 0abc0def0ghi(0–7) (0–7) (0–7)Three lower digits51.2% (512 states)
37.5% (384 states)100cdefghi 100c0def0ghi(8–9) (0–7) (0–7)Two lower digits,
one higher digit
38.4% (384 states)
101cabfghi 0abc100f0ghi(0–7) (8–9) (0–7)
110cdefabi 0abc0def100i(0–7) (0–7) (8–9)
9.375% (96 states)111c00fabi 0abc100f100i(0–7) (8–9) (8–9)One lower digit,
two higher digits
9.6% (96 states)
111c01fdei 100c0def100i(8–9) (0–7) (8–9)
111c10fghi100c100f0ghi(8–9) (8–9) (0–7)
3.125% (32 states, 8 used)111c11f(0)(0)i 100c100f100i(8–9) (8–9) (8–9)Three higher digits, bits b2 and b1 are don't care0.8% (8 states)
  • This encoding is not parity-preserving.[15]

Storage efficiency

Storage efficiency
BCD Necessary bits Bit difference
Digits States Bits Binary code space Binary encoding [A] 2-digit encoding [B] 3-digit encoding [C] Mixed encoding Mixed vs. Binary Mixed vs. BCD
1104164(7)(10)4 [1×A]00
2100812877(10)7 [1×B]0−1
3100012102410(14)1010 [1×C]0−2
41000016163841414(20)14 [2×B]0−2
51000002013107217(21)(20)17 [1×C+1×B]0−3
6100000024104857620212020 [2×C]0−4
710000000281677721624(28)(30)24 [2×C+1×A]0−4
8100000000321342177282728(30)27 [2×C+1×B]0−5
9100000000036107374182430(35)3030 [3×C]0−6
101000000000040171798691843435(40)34 [3×C+1×A]0−6
111000000000004413743895347237(42)(40)37 [3×C+1×B]0−7
12100000000000048109951162777640424040 [4×C]0−8
1310000000000000521759218604441644(49)(50)44 [4×C+1×A]0−8
14100000000000000561407374883553284749(50)47 [4×C+1×B]0−9
15100000000000000060112589990684262450(56)5050 [5×C]0−10
161000000000000000064180143985094819845456(60)54 [5×C+1×A]0−10
171000000000000000006814411518807585587257(63)(60)57 [5×C+1×B]0−11
18100000000000000000072115292150460684697660636060 [6×C]0−12
1910000000000000000000761844674407370955161664(70)(70)64 [6×C+1×A]0−12
20806770(70)67 [6×C+1×B]0−13
218470(77)7070 [7×C]0−14
22887477(80)74 [7×C+1×A]0−14
239277(84)(80)77 [7×C+1×B]0−15
249680848080 [8×C]0−16
2510084(91)(90)84 [8×C+1×A]0−16
261048791(90)87 [8×C+1×B]0−17
2710890(98)9090 [9×C]0−18
281129498(100)94 [9×C+1×A]0−18
2911697(105)(100)97 [9×C+1×B]0−19
30120100105100100 [10×C]0−20
31124103(112)(110)104 [10×C+1×A]+1−20
32128107112(110)107 [10×C+1×B]0−21
33132110(119)110110 [11×C]0−22
34136113119(120)114 [11×C+1×A]+1−22
35140117(126)(120)117 [11×C+1×B]0−23
36144120126120120 [12×C]0−24
37148123(133)(130)124 [12×C+1×A]+1−24
38152127133(130)127 [12×C+1×B]0−25

See also

Notes

  1. 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.

References

  1. Muller, Jean-Michel; Brisebarre, Nicolas; de Dinechin, Florent; Jeannerod, Claude-Pierre; Lefèvre, Vincent; Melquiond, Guillaume; Revol, Nathalie; Stehlé, Damien; Torres, Serge (2010). Handbook of Floating-Point Arithmetic (1 ed.). Birkhäuser. doi:10.1007/978-0-8176-4705-6. ISBN 978-0-8176-4704-9. LCCN 2009939668.
  2. Hertz, Theodore M. (1971-11-02) [1969-12-15]. "System for the compact storage of decimal numbers" (Patent). Whittier, California, USA: North American Rockwell Corporation. US Patent US3618047A. Retrieved 2018-07-18. (8 pages) (NB. This expired patent discusses a coding system very similar to Chen-Ho, also cited as prior art in the Chen–Ho patent.)
  3. "We hear that..." Physics Today. 12 (2). American Institute of Physics (AIP). 1959. p. 62. doi:10.1063/1.3060696. ISSN 0031-9228. Archived from the original on 2020-06-24. Retrieved 2020-06-24. (1 page)
  4. Parker, David (2003). "Honorary Fellow - A Citation - Professor Chen Tien Chi" (PDF). List of Honorary Fellows. The Chinese University of Hong Kong (CUHK). Archived (PDF) from the original on 2014-12-25. Retrieved 2020-06-24. (2 pages)
  5. "CHEN Tien Chi". The Chinese University of Hong Kong (CUHK). 2013-01-12. Archived from the original on 2015-10-23. Retrieved 2016-02-07.
  6. 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.
  7. "Scientist Given Task To Set Up Science-Oriented Industrial Park". Science Bulletin. 11 (2). Taipei, Taiwan: National Science Council. 1979-02-01. p. 1. ISSN 1607-3509. OCLC 1658005. Archived from the original on 2020-06-25. Retrieved 2020-06-24. (1 page)
  8. Tseng, Li-Ling (1988-04-01). "High-Tech Leadership: Irving T. Ho". Taiwan Info. Archived from the original on 2016-02-08. Retrieved 2016-02-08.
  9. "Taiwan's Silicon Valley: The Evolution of Hsinchu Industrial Park". Freeman Spogli Institute for International Studies. Stanford University, Stanford, California, USA. 2000-01-11. Archived from the original on 2020-06-26. Retrieved 2017-05-02.
  10. "Irving T. Ho". San Jose Mercury News. 2003-04-26. Archived from the original on 2020-06-25. Retrieved 2020-06-25.
  11. 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.
  12. Chen, 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)
  13. IBM资深专家Frank Tung博士8月4日来我校演讲 [IBM senior expert Dr. Frank Tung came to our school on 4 August to give a speech] (in Chinese and English). Guangzhou, China: South China University of Technology (SCUT). 2004-08-04. Archived from the original on 2004-12-08. Retrieved 2016-02-06.
  14. Chen, Tien Chi; Ho, Irving Tze (1974-10-15) [1973-06-18]. Written at San Jose, California, USA & Poughkeepsie, New York, USA. "Binary coded decimal conversion apparatus" (Patent). Armonk, New York, USA: International Business Machines Corporation (IBM). US Patent US3842414A. Retrieved 2018-07-18. (14 pages) (NB. This expired patent is about the Chen–Ho algorithm.)
  15. Chen, Tien Chi; Ho, Irving Tze (January 1975) [April 1974]. "Storage-Efficient Representation of Decimal Data". Communications of the ACM. IBM San Jose Research Laboratory, San Jose, California, USA & IBM Systems Products Division, Poughkeepsie/East Fishkill, New York, USA: Association for Computing Machinery. 18 (1): 49–52. doi:10.1145/360569.360660. ISSN 0001-0782. S2CID 14301378. Archived from the original on 2020-06-24. Retrieved 2020-06-24. (4 pages)
  16. 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.
  17. Cowlishaw, Michael Frederic (2014) [June 2000]. "A Summary of Chen-Ho Decimal Data encoding". IBM. Archived from the original on 2015-09-24. Retrieved 2016-02-07.
  18. Smith, Alan Jay (August 1975) [April 1975]. "Comments on a paper by T. C. Chen and I. T. Ho". Communications of the ACM. University of California, Berkeley, California, USA. 18 (8): 463. doi:10.1145/360933.360986. eISSN 1557-7317. ISSN 0001-0782. S2CID 20910959. CODEN CACMA2. Archived from the original on 2020-06-03. Retrieved 2020-06-03. (1 page) (NB. A publication also discussing Chen–Ho alternatives and variations.)
  19. Sacks-Davis, Ron (1982-11-01) [January 1982]. "Applications of Redundant Number Representations to Decimal Arithmetic" (PDF). The Computer Journal. Department of Computer Science, Monash University, Clayton, Victoria, Australia: Wiley Heyden Ltd. 25 (4): 471–477. doi:10.1093/comjnl/25.4.471. Archived from the original (PDF) on 2020-06-24. Retrieved 2020-06-24. (7 pages)
  20. Cowlishaw, Michael Frederic (2003-02-25) [2002-05-20, 2001-01-27]. Written at Coventry, UK. "Decimal to binary coder/decoder" (Patent). Armonk, New York, USA: International Business Machines Corporation (IBM). US Patent US6525679B1. Retrieved 2018-07-18 (6 pages) and Cowlishaw, Michael Frederic (2007-11-07) [2004-01-14, 2002-08-14, 2001-09-24, 2001-01-27]. Written at Winchester, Hampshire, UK. "Decimal to binary coder/decoder" (Patent). Armonk, New York, USA: International Business Machines Corporation (IBM). European Patent EP1231716A2. Retrieved 2018-07-18. (9 pages) (NB. This patent about DPD also discusses the Chen–Ho algorithm.)
  21. Cowlishaw, Michael Frederic (2002-08-07) [May 2002]. "Densely Packed Decimal Encoding". IEE Proceedings - Computers and Digital Techniques. London, UK: Institution of Electrical Engineers (IEE). 149 (3): 102–104. doi:10.1049/ip-cdt:20020407. ISSN 1350-2387. Retrieved 2016-02-07. (3 pages)
  22. Cowlishaw, Michael Frederic (2007-02-13) [2000-10-03]. "A Summary of Densely Packed Decimal encoding". IBM. Archived from the original on 2015-09-24. Retrieved 2016-02-07.
  23. Savard, John J. G. (2018) [2007]. "Chen-Ho Encoding and Densely Packed Decimal". quadibloc. Archived from the original on 2018-07-03. Retrieved 2018-07-16.
  24. 7070/7074 Compatibility Feature for IBM System/370 Models 165, 165 II, and 168 (PDF) (2 ed.). IBM. June 1973 [1970]. GA22-6958-1 (File No. 5/370-13). Archived (PDF) from the original on 2018-07-22. Retrieved 2018-07-21. (31+5 pages)

Further reading

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.