Hamming Distance Calculator

Calculate the Hamming distance between two binary strings. Hamming distance is the number of positions where the bits differ.

How to Use This Calculator

  1. Enter the first binary string (only 0s and 1s).
  2. Enter the second binary string (must be the same length as the first).
  3. The calculator displays the Hamming distance (number of differing bit positions).
  4. Use this to understand error detection, coding theory, or measure code differences.

Hamming Distance Formula

Hamming distance is calculated by counting differing positions:

Hamming Distance = Σ (bit₁[i] ≠ bit₂[i]) for i = 0 to length-1

Example: "10101010" and "11001100": Compare bit by bit: positions 1, 2, 5, 6 differ. Hamming distance = 4. For "1111" and "0000": All 4 positions differ, so Hamming distance = 4.

Full Description

Hamming distance is a fundamental concept in coding theory and information theory. It measures the number of positions where two strings of equal length differ. For binary strings, it's simply the number of bit positions that differ. Hamming distance is essential for error detection and correction, as it quantifies how "different" two codes are.

The concept is named after Richard Hamming, who also invented Hamming codes. Hamming distance is used to determine the error detection and correction capability of codes: A code with minimum Hamming distance d can detect up to d-1 errors and correct up to ⌊(d-1)/2⌋ errors. This makes it crucial for designing reliable communication and storage systems.

This calculator helps you determine Hamming distance between binary strings. Enter two binary strings of equal length, and it counts the number of positions where they differ. Use it to understand error correction, analyze codes, measure code differences, or learn about coding theory. Hamming distance is fundamental to reliable data transmission and error correction.

Frequently Asked Questions

What is Hamming distance?

Hamming distance is the number of positions where two strings of equal length differ. For binary strings, it's the number of bit positions that differ. For example, "1010" and "1100" have Hamming distance 2 (bits at positions 1 and 2 differ).

What is Hamming distance used for?

Hamming distance is used in error detection and correction, coding theory, information theory, and pattern matching. It measures how different two codes are, which is essential for error correction codes like Hamming codes.

Can I calculate Hamming distance for non-binary strings?

Yes! Hamming distance works for any strings of equal length. For example, "CAT" and "DOG" have Hamming distance 3 (all three characters differ). The calculator currently focuses on binary strings, but the concept applies to any equal-length strings.

What is the minimum Hamming distance?

The minimum Hamming distance of a code is the smallest Hamming distance between any two distinct codewords. It determines error detection and correction capability: A code with minimum distance d can detect d-1 errors and correct ⌊(d-1)/2⌋ errors.