aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/vespa/eval/eval/hamming_distance.h
blob: a21d48ceaa42c0ad9698628ff75a8b31c7a926e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

namespace vespalib::eval {

inline double hamming_distance(double a, double b) {
    uint8_t x = (uint8_t) (int8_t) a;
    uint8_t y = (uint8_t) (int8_t) b;
    return __builtin_popcount(x ^ y);
}

}