How can I efficiently store binary codes? For certain fixed sizes, such as 32 bits, there are primitive types that can be used. But what if I my binary codes are much longer?
What is the fastest way to compute the Hamming distance between two binary codes?
std::bitset<N>
, defined in the <bitset>
header, where N
is the number of bits (not bytes).a
and b
using (a ^ b).count()
.