# Hamming Distance - 26 May 2014 at 23:16

## Hamming Distance

The Hamming distance can be essentially thought of as the number of differences counted between two strings of equal length. Hamming distances are used in applications such as data transmission and error detection.

Consider the following 16 bit binary strings:

0010000111010011
1100010010010011

Masking out any bits that are in the same position within the string, but do not have equivalent values produces:

0010000111010011
1100010010010011
***00*0*1*010011

Counting all the asterisks gives us a Hamming distance of 6.

Consider the following words:

November
December

Masking out any letters that are in the same position within the string, but do not have equivalent values produces:

November
December
***ember

So the Hamming distance is 3.

You could apply this to integers as well. Consider the following numbers:

2349822134
2390423498

Masking out any integers that are in the same position within the number, but do not have equivalent values produces:

2349822134
2390423498
23***2****

So the Hamming distance here is 7.