# Weight-two code[1]

## Description

A length-\(n\) binary code whose codewords all have Hamming weight two. Such codes provide slightly extra redundancy for storage of small-scale information such as ZIP codes or decimal digits.

For example, the two-in-five code has a size 10, thereby providing an encoding for the decimal digits 0 through 9. Such a code detects some single bit-flips as well as unidirectional errors using the fact that each codeword is weight-two. The code fails for any sequence of flips that maintains the constant weight.

## Realizations

Two-in-five, also known as the two-out-of-five code, was used in the United States Postal Service's POSTNET barcode system as well as the Postal Alpha-numeric Encoding Technique (PLANET).Two-in-five code forms the numerical part of the Code 39 barcode encoding.Two-in-five code was used on early IBM computers [2][3].

## Notes

See Ch. 19 of book [4] on weight-two codes.

## Parents

## References

- [1]
- R. W. Hamming, Letter, April 5, 1978.
- [2]
- J. Svigals, “IBM 7070 data processing system”, Papers presented at the the March 3-5, 1959, western joint computer conference on XX - IRE-AIEE-ACM '59 (Western) (1959). DOI
- [3]
- T. M. Thompson, From Error-Correcting Codes Through Sphere Packings To Simple Groups, Mathematical Association of America, 1983.
- [4]
- W. C. Huffman, J.-L. Kim, and P. Solé, Concise Encyclopedia of Coding Theory (Chapman and Hall/CRC, 2021). DOI

## Zoo code information

## Cite as:

“Weight-two code”, The Error Correction Zoo (V. V. Albert & P. Faist, eds.), 2022. https://errorcorrectionzoo.org/c/weight_two

Github: https://github.com/errorcorrectionzoo/eczoo_data/tree/main/codes/classical/bits/easy/weight_two.yml.