Binary Hamming distance calculator
Count differing bit positions between two equal-length binary strings. Enter your values below to see the result and method.
inputs.
Related calculators and articles
Compare methods and explore more free tools in computer science.
How to use the Binary Hamming distance calculator
Count the bit positions that differ between two equal-length binary strings. Leading zeroes are positions and must be retained in both inputs.
What it calculates
Count differing bit positions between two equal-length binary strings. The strings must have equal length. Identical strings have distance 0; if every bit differs, the distance equals the string length.
Inputs and units
Enter strings containing only 0 and 1 with equal length; leading zeroes are significant.
- First bit string: First equal-length binary word; preserve leading zeroes.
- Second bit string: Second binary word, with the same number of positions as the first.
Formula and method
distance = count of positions where xᵢ ≠ yᵢ
Compare corresponding bit positions and count mismatches. Equal string lengths are required because each position must have a counterpart.
Worked example
For 1011101 and 1001001, two positions differ, so the Hamming distance is 2.
How to interpret the result
The integer result is the number of positions that must change to make the two equal-length bit strings identical.
Assumptions and limitations
The strings must contain only 0 and 1 and must have equal length. Leading zeros are significant.
Frequently asked questions
What contributes one unit to binary Hamming distance?
Each position contributes 1 when the two bits differ and 0 when they match; the strings must have equal length.
Do the two bit strings need the same length?
Yes. Hamming distance compares corresponding positions, so inputs of different lengths are rejected rather than padded or truncated.
How do I use the Binary Hamming distance calculator?
Enter First bit string, Second bit string. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Binary Hamming distance?
For 1011101 and 1001001, two positions differ, so the Hamming distance is 2.
What does the Binary Hamming distance calculator calculate?
Free Binary Hamming distance calculator. Count differing bit positions between two equal-length binary strings. Review its formula, example, and assumptions.
Read the calculation methodology and privacy policy.
Source: NIST Dictionary of Algorithms and Data Structures: Hamming distance. Defines Hamming distance as the count of differing positions for equal-length words.