1#include <Functions/FunctionFactory.h>
2#include <Functions/FunctionBinaryArithmetic.h>
3#include <Core/Defines.h>
4
5
6namespace DB
7{
8
9template <typename A, typename B>
10struct BitTestImpl
11{
12 using ResultType = UInt8;
13
14 template <typename Result = ResultType>
15 NO_SANITIZE_UNDEFINED static inline Result apply(A a, B b)
16 {
17 return (typename NumberTraits::ToInteger<A>::Type(a) >> typename NumberTraits::ToInteger<B>::Type(b)) & 1;
18 }
19
20#if USE_EMBEDDED_COMPILER
21 static constexpr bool compilable = false; /// TODO
22#endif
23};
24
25struct NameBitTest { static constexpr auto name = "bitTest"; };
26using FunctionBitTest = FunctionBinaryArithmetic<BitTestImpl, NameBitTest>;
27
28void registerFunctionBitTest(FunctionFactory & factory)
29{
30 factory.registerFunction<FunctionBitTest>();
31}
32
33}
34