Skip to content
Surf Wiki
Save to docs
general/binary-arithmetic

From Surf Wiki (app.surf) — the open knowledge base

Chen–Ho encoding

Memory-efficient binary encoding of decimal digits


Memory-efficient binary encoding of 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), 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 and by Tien Chi Chen (陳天機) (1928–) in 1971.

Hertz of Rockwell filed a patent for his encoding in 1969, which was granted in 1971.

Chen first discussed his ideas with Irving Tze Ho (何宜慈) (1921–2003) in 1971. Chen and Ho were both working for IBM at the time, albeit in different locations. Chen also consulted with Frank Chin Tung to verify the results of his theories independently. IBM filed a patent in their name in 1973, which was granted in 1974. At least by 1973, Hertz's earlier work must have been known to them, as the patent cites his patent as prior art.

With input from Joseph D. Rutledge and John C. McPherson, the final version of the Chen–Ho encoding was circulated inside IBM in 1974 and published in 1975 in the journal Communications of the ACM. 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, Chen's encoding in 1982 and became known as Chen–Ho encoding or Chen–Ho algorithm since 2000. After having filed a patent for it in 2001, 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. 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). Of the 1024 states possible by using 10 bits, it leaves only 24 states unused (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.

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.

Larger sets of decimal digits could be divided into three- and two-digit groups.

The patents also discuss the possibility to adapt the scheme to digits encoded in any other decimal codes than 8-4-2-1 BCD, like f.e. Excess-3, Excess-6, Jump-at-2, Jump-at-8, Gray, Glixon, O'Brien type-I and Gray–Stibitz code. 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.

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

{{anchor|7-bit encodings}}Encodings for two decimal digits

{{anchor|Hertz|7-bit Hertz}}Hertz encoding

Binary encodingDecimal digitsCode space (128 states)b6b5b4b3b2b1b0d1d0Values encodedDescriptionOccurrences (100 states)
50% (64 states)**0**abcdef0**abc**0**def**(0–7) (0–7)Two lower digits64% (64 states)
12.5% (16 states)**1****1****0**cdef100**c**0**def**(8–9) (0–7)One lower digit,
one higher digit16% (16 states)
12.5% (16 states)**1****0****1**fabc0**abc**100**f**(0–7) (8–9)16% (16 states)
12.5% (16 states, 4 used)**1****1****1**cxxf100**c**100**f**(8–9) (8–9)Two higher digits4% (4 states)
12.5% (16 states, 0 used)**1****0****0**xxxx0% (0 states)
  • This encoding is not parity-preserving.

Early Chen–Ho encoding, method A

Binary encodingDecimal digitsCode space (128 states)b6b5b4b3b2b1b0d1d0Values encodedDescriptionOccurrences (100 states)
50% (64 states)**0**abcdef0**abc**0**def**(0–7) (0–7)Two lower digits64% (64 states)
25% (32 states, 16 used)**1****0**x (b)cdef100**c**0**def**(8–9) (0–7)One lower digit,
one higher digit16% (16 states)
12.5% (16 states)**1****1****0**fabc0**abc**100**f**(0–7) (8–9)16% (16 states)
12.5% (16 states, 4 used)**1****1****1**cx (a)x (b)f100**c**100**f**(8–9) (8–9)Two higher digits4% (4 states)
  • This encoding is not parity-preserving.

Early Chen–Ho encoding, method B

Binary encodingDecimal digitsCode space (128 states)b6b5b4b3b2b1b0d1d0Values encodedDescriptionOccurrences (100 states)
50% (64 states)**0**abcdef0**abc**0**def**(0–7) (0–7)Two lower digits64% (64 states)
12.5% (16 states)**1****0**c**0**def100**c**0**def**(8–9) (0–7)One lower digit,
one higher digit16% (16 states)
12.5% (16 states, 4 used)**1****0**c**1**xxf100**c**100**f**(8–9) (8–9)Two higher digits4% (4 states)
12.5% (16 states)**1****1**f**0**abc0**abc**100**f**(0–7) (8–9)One lower digit,
one higher digit16% (16 states)
12.5% (16 states, 0 used)**1****1**x**1**xxx0% (0 states)
  • This encoding is not parity-preserving.

{{anchor|7-bit Chen–Ho}}Patented and final Chen–Ho encoding

Binary encodingDecimal digitsCode space (128 states)b6b5b4b3b2b1b0d1d0Values encodedDescriptionOccurrences (100 states)
50% (64 states)**0**abcdef0**abc**0**def**(0–7) (0–7)Two lower digits64% (64 states)
25.0% (32 states, 16 used)**1****0**x (b)cdef100**c**0**def**(8–9) (0–7)One lower digit,
one higher digit16% (16 states)
12.5% (16 states)**1****1****1**cabf0**abc**100**f**(0–7) (8–9)16% (16 states)
12.5% (16 states, 4 used)**1****1****0**cx (a)x (b)f100**c**100**f**(8–9) (8–9)Two higher digits4% (4 states)
  • Assuming certain values for the don't-care bits (f.e. 0), this encoding is parity-preserving.

{{anchor|10-bit encodings}}Encodings for three decimal digits

{{anchor|10-bit Hertz}}Hertz encoding

Binary encodingDecimal digitsCode space (1024 states)b9b8b7b6b5b4b3b2b1b0d2d1d0Values encodedDescriptionOccurrences (1000 states)
50.0% (512 states)**0**abcdefghi0**abc**0**def**0**ghi**(0–7) (0–7) (0–7)Three lower digits51.2% (512 states)
37.5% (384 states)**1****0****0**cdefghi100**c**0**def**0**ghi**(8–9) (0–7) (0–7)Two lower digits,
one higher digit38.4% (384 states)
**1****0****1**fabcghi0**abc**100**f**0**ghi**(0–7) (8–9) (0–7)
**1****1****0**iabcdef0**abc**0**def**100**i**(0–7) (0–7) (8–9)
9.375% (96 states)**1****1****1**f**0****0**iabc0**abc**100**f**100**i**(0–7) (8–9) (8–9)One lower digit,
two higher digits9.6% (96 states)
**1****1****1**c**0****1**idef100**c**0**def**100**i**(8–9) (0–7) (8–9)
**1****1****1**c**1****0**fghi100**c**100**f**0**ghi**(8–9) (8–9) (0–7)
3.125% (32 states, 8 used)**1****1****1**c**1****1**f(**0**)(**0**)i100**c**100**f**100**i**(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

Binary encodingDecimal digitsCode space (1024 states)b9b8b7b6b5b4b3b2b1b0d2d1d0Values encodedDescriptionOccurrences (1000 states)
50.0% (512 states)**0**abcdefghi0**abc**0**def**0**ghi**(0–7) (0–7) (0–7)Three lower digits51.2% (512 states)
37.5% (384 states)**1****0****0**cdefghi100**c**0**def**0**ghi**(8–9) (0–7) (0–7)Two lower digits,
one higher digit38.4% (384 states)
**1****0****1**fghiabc0**abc**100**f**0**ghi**(0–7) (8–9) (0–7)
**1****1****0**iabcdef0**abc**0**def**100**i**(0–7) (0–7) (8–9)
9.375% (96 states)**1****1****1****0****0**fiabc0**abc**100**f**100**i**(0–7) (8–9) (8–9)One lower digit,
two higher digits9.6% (96 states)
**1****1****1****0****1**icdef100**c**0**def**100**i**(8–9) (0–7) (8–9)
**1****1****1****1****0**cfghi100**c**100**f**0**ghi**(8–9) (8–9) (0–7)
3.125% (32 states, 8 used)**1****1****1****1****1**cfi(**0**)(**0**)100**c**100**f**100**i**(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

Binary encodingDecimal digitsCode space (1024 states)b9b8b7b6b5b4b3b2b1b0d2d1d0Values encodedDescriptionOccurrences (1000 states)
50.0% (512 states)**0**abdeghcfi0**abc**0**def**0**ghi**(0–7) (0–7) (0–7)Three lower digits51.2% (512 states)
37.5% (384 states)**1****0****0**deghcfi100**c**0**def**0**ghi**(8–9) (0–7) (0–7)Two lower digits,
one higher digit38.4% (384 states)
**1****0****1**abghcfi0**abc**100**f**0**ghi**(0–7) (8–9) (0–7)
**1****1****0**deabcfi0**abc**0**def**100**i**(0–7) (0–7) (8–9)
9.375% (96 states)**1****1****1****1****0**abcfi0**abc**100**f**100**i**(0–7) (8–9) (8–9)One lower digit,
two higher digits9.6% (96 states)
**1****1****1****0****1**decfi100**c**0**def**100**i**(8–9) (0–7) (8–9)
**1****1****1****0****0**ghcfi100**c**100**f**0**ghi**(8–9) (8–9) (0–7)
3.125% (32 states, 8 used)**1****1****1****1****1**(**0**)(**0**)cfi100**c**100**f**100**i**(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.

{{anchor|10-bit Chen–Ho}}Final Chen–Ho encoding

Binary encodingDecimal digitsCode space (1024 states)b9b8b7b6b5b4b3b2b1b0d2d1d0Values encodedDescriptionOccurrences (1000 states)
50.0% (512 states)**0**abcdefghi0**abc**0**def**0**ghi**(0–7) (0–7) (0–7)Three lower digits51.2% (512 states)
37.5% (384 states)**1****0****0**cdefghi100**c**0**def**0**ghi**(8–9) (0–7) (0–7)Two lower digits,
one higher digit38.4% (384 states)
**1****0****1**cabfghi0**abc**100**f**0**ghi**(0–7) (8–9) (0–7)
**1****1****0**cdefabi0**abc**0**def**100**i**(0–7) (0–7) (8–9)
9.375% (96 states)**1****1****1**c**0****0**fabi0**abc**100**f**100**i**(0–7) (8–9) (8–9)One lower digit,
two higher digits9.6% (96 states)
**1****1****1**c**0****1**fdei100**c**0**def**100**i**(8–9) (0–7) (8–9)
**1****1****1**c**1****0**fghi100**c**100**f**0**ghi**(8–9) (8–9) (0–7)
3.125% (32 states, 8 used)**1****1****1**c**1****1**f(**0**)(**0**)i100**c**100**f**100**i**(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.

Storage efficiency

BCDNecessary bitsBit differenceDigitsStatesBitsBinary code spaceBinary encoding [A]2-digit encoding [B]3-digit encoding [C]Mixed encodingMixed vs. BinaryMixed vs. BCD
144(7)(10)4 [1×A]00
2877(10)7 [1×B]0−1
31210(14)1010 [1×C]0−2
4161414(20)14 [2×B]0−2
52017(21)(20)17 [1×C+1×B]0−3
62420212020 [2×C]0−4
72824(28)(30)24 [2×C+1×A]0−4
8322728(30)27 [2×C+1×B]0−5
93630(35)3030 [3×C]0−6
10403435(40)34 [3×C+1×A]0−6
114437(42)(40)37 [3×C+1×B]0−7
124840424040 [4×C]0−8
135244(49)(50)44 [4×C+1×A]0−8
14564749(50)47 [4×C+1×B]0−9
156050(56)5050 [5×C]0−10
16645456(60)54 [5×C+1×A]0−10
176857(63)(60)57 [5×C+1×B]0−11
187260636060 [6×C]0−12
197664(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

Notes

References

References

  1. (2010). "Handbook of Floating-Point Arithmetic". [[Birkhäuser]].
  2. . (1959). ["We hear that..."](https://physicstoday.scitation.org/doi/abs/10.1063/1.3060696?journalCode=pto). *[[American Institute of Physics]] (AIP)*.
  3. (2003). "Honorary Fellow - A Citation - Professor Chen Tien Chi". [[The Chinese University of Hong Kong]] (CUHK).
  4. . (2013-01-12). ["CHEN Tien Chi"](http://www.cse.cuhk.edu.hk/v7/en/people/tcchen.html). *[[The Chinese University of Hong Kong]] (CUHK)*.
  5. (2014-08-15). Classical Chinese Poems in English. link
  6. . (1979-02-01). ["Scientist Given Task To Set Up Science-Oriented Industrial Park"](https://ejournal.stpi.narl.org.tw/index/items/download?viId=D9F1CC76-75FC-4440-8530-AC0B4B9CCE82&usg=AOvVaw0NgCMp2GIN8d2aXRbfhNMt). *[[National Science Council]]*.
  7. (1988-04-01). "High-Tech Leadership: Irving T. Ho". [[Taiwan Info]].
  8. . (2003-04-26). ["Irving T. Ho"](https://www.legacy.com/obituaries/mercurynews/obituary.aspx?n=irving-t-ho&pid=967196). *[[San Jose Mercury News]]*.
  9. . (2004-08-04). *[[South China University of Technology]] (SCUT)*. [link](http://www2.scut.edu.cn/software/news/news13.htm)
  10. (1971-03-12). "Decimal-binary integer conversion scheme". [[IBM]].
  11. (1971-03-29). "Decimal Number Compression". [[IBM]].
  12. (1974-06-25). "Storage-Efficient Representation of Decimal Data". [[IBM]].
  13. (January 1975). "Storage-Efficient Representation of Decimal Data". [[Association for Computing Machinery]].
  14. (August 1975). "Comments on a paper by T. C. Chen and I. T. Ho". [[Communications of the ACM]].
  15. (2014). "A Summary of Chen-Ho Decimal Data encoding". [[IBM]].
  16. (2002-08-07). "Densely Packed Decimal Encoding". [[Institution of Electrical Engineers]] (IEE).
  17. (1974-10-15). "Binary coded decimal conversion apparatus". [[International Business Machines Corporation]] (IBM).
  18. (2007-02-13). "A Summary of Densely Packed Decimal encoding". [[IBM]].
  19. (2003-02-25). "Decimal to binary coder/decoder". [[International Business Machines Corporation]] (IBM).
  20. (1971-11-02). "System for the compact storage of decimal numbers". [[North American Rockwell Corporation]].
  21. (2018). "Chen-Ho Encoding and Densely Packed Decimal". quadibloc.
  22. . (June 1973). ["7070/7074 Compatibility Feature for IBM System/370 Models 165, 165 II, and 168"](http://www.bitsavers.org/pdf/ibm/370/compatibility_feature/GA22-6958-1_707x_Compatibility_Feature_for_IBM-370_165_168.pdf). *[[IBM]]*.
  23. (1982-11-01). "Applications of Redundant Number Representations to Decimal Arithmetic". [[Wiley Heyden Ltd]].
Info: Wikipedia Source

This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.

Want to explore this topic further?

Ask Mako anything about Chen–Ho encoding — get instant answers, deeper analysis, and related topics.

Research with Mako

Free with your Surf account

Content sourced from Wikipedia, available under CC BY-SA 4.0.

This content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.

Report