---
title: "Define Hamming weight and Hamming distance"
subject: "Communication Systems"
chapter: 8
key: "semester_6/communication_systems:define-hamming-weight-distance"
source: https://www.bctengineer.com/q/semester_6/communication_systems/define-hamming-weight-distance
site: BCT Engineering
---

# Define Hamming weight and Hamming distance

Communication Systems · Chapter 8: Error Detection and Correction Coding

- Asked in: 2070 Asar (CS II), 2 marks
- Video: [Error Correcting Codes: What is Hamming Distance and Minimum Hamming Distance ?](https://www.youtube.com/watch?v=7SVSXiWc0-o) — ALL ABOUT ELECTRONICS
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/communication_systems/define-hamming-weight-distance
- Whole chapter: https://www.bctengineer.com/md/semester_6/communication_systems/chapter-8

## Question

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.

## Answer

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

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

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which is the Hamming weight of 1011001?
   A. 3
   B. 4
   C. 5
   D. 7
   Answer: B. There are four 1s in 1011001. (Key point: Hamming weight)

2. What is d(1011001, 1001011)?
   A. 2
   B. 1
   C. 3
   D. 4
   Answer: A. XOR gives 0010010 with weight 2. (Key point: Hamming distance)

3. A code has d_min = 5. How many errors can it correct?
   A. 1
   B. 4
   C. 5
   D. 2
   Answer: D. Correctable errors = floor((5-1)/2) = 2; it detects up to 4. (Key point: Error capability)

## Related in Communication Systems

- [Hamming weight and distance; (7,4) cyclic code for 1011](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-weight-cyclic-1011) — Communication Systems, chapter 8, asked 2×
- [Hamming weight/distance; validate x = 0111000 with given H](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-code-vector-0111000) — Communication Systems, chapter 8, asked 2×
- [Hamming distance and weight; (6,3) code check for 100101](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-6-3-h-100101) — Communication Systems, chapter 8
- [Hamming distance and weight; rate 1/3 convolutional encoder](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-third-rate-convolutional) — Communication Systems, chapter 8
- [Hamming weight and distance; validate code 100011](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-6-3-h-100011) — Communication Systems, chapter 8
- [Hamming distance and weight importance; syndrome decoding](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Ahamming-importance-syndrome-decoding) — Communication Systems, chapter 8

## Related in other subjects

- [Hamming distance and minimum distance](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Ahamming-distance-define) — Data Communication, chapter 8, asked 2×
- [Redundancy, Hamming distance, linear vs cyclic](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Aredundancy-hamming-linear-cyclic) — Data Communication, chapter 8
- [Minimum Hamming distance; find k and n](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Amin-hamming-k-n) — Data Communication, chapter 8
