Hamming distance calculation
Posted onThis 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 <iostream> #include <bitset> int popcount64(const hash_t& val) noexcept { int ret; __asm__ ("popcnt %1, %1" : "=r" (ret) : "0" (val)); return ret; […]