aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/vespa/eval/eval/extract_bit.h
blob: e0e3994092b90a2a0c40ab140a3c06b2cfd350fd (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 extract_bit(double a, double b) {
    int8_t value = (int8_t) a;
    uint32_t n = (uint32_t) b;
    return ((n < 8) && bool(value & (1 << n))) ? 1.0 : 0.0;
}

}