aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/vespa/eval/eval/extract_bit.h
blob: 7972850eb0f31a8aa91aaf80c36580eceecf9d47 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
// Copyright Yahoo. 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;
}

}