Hamming distance calculation
This is a small snippet of how to calculate hamming distance in cpp with small bit of assembly for doing a population count. Code typedef unsigned long long hash_t; #include #include int popcount64(const hash_t& val) noexcept { int ret; __asm__ (“popcnt %1, %1” : “=r” (ret) : “0” (val)); return ret; } int hamming_distance(const hash_t& …