Skip to main content

Define Hamming weight and Hamming distance

Short answer

Hamming weight is the number of non-zero bits in a code vector. Hamming distance between two equal-length code vectors is the number of bit positions where they differ, equal to the weight of their bitwise XOR.

Define Hamming Weight and Hamming Distance.

  • Hamming weight w(c)w(\mathbf{c}): the number of non-zero (1) bits in a code vector. Example: w(1011001)=4w(1011001)=4.
  • Hamming distance d(c1,c2)d(\mathbf{c}_1,\mathbf{c}_2): the number of bit positions in which two code vectors of the same length differ; d(c1,c2)=w(c1⊕c2)d(\mathbf{c}_1,\mathbf{c}_2)=w(\mathbf{c}_1\oplus\mathbf{c}_2). Example: c1=1011001\mathbf{c}_1=1011001, c2=1001011\mathbf{c}_2=1001011; c1⊕c2=0010010\mathbf{c}_1\oplus\mathbf{c}_2=0010010, so d=2d=2.

The smallest distance between any pair of codewords, dmind_{min}, sets the error capability: a code detects dmin−1d_{min}-1 errors and corrects ⌊(dmin−1)/2⌋\lfloor(d_{min}-1)/2\rfloor errors.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Communication Systems chapter 8 questions →