# 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 Ref. [4] on weight-two codes.

## Parents

## Cousin

- Two-weight code — Codewords of two-weight codes have one of two possible Hamming weights, while those of weight-two codes have Hamming weight two.

## 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. Thompson, From Error-Correcting Codes Through Sphere Packings to Simple Groups (American Mathematical Society, 1983) DOI
- [4]
- A. E. Brouwer, "Two-weight Codes." Concise Encyclopedia of Coding Theory (Chapman and Hall/CRC, 2021) DOI

## Page edit log

- Victor V. Albert (2022-08-12) — most recent

## 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/edit/main/codes/classical/bits/easy/weight_two.yml.