hamming distance and conversion to binary