2018-11-26 16:20:40 +00:00
|
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
#include <Functions/FunctionBinaryArithmetic.h>
|
2019-07-08 22:30:30 +00:00
|
|
|
#include <Core/Defines.h>
|
|
|
|
|
2018-11-26 16:20:40 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
template <typename A, typename B>
|
|
|
|
struct BitTestImpl
|
|
|
|
{
|
|
|
|
using ResultType = UInt8;
|
|
|
|
|
|
|
|
template <typename Result = ResultType>
|
2019-07-08 22:30:30 +00:00
|
|
|
NO_SANITIZE_UNDEFINED static inline Result apply(A a, B b)
|
2018-11-26 16:20:40 +00:00
|
|
|
{
|
|
|
|
return (typename NumberTraits::ToInteger<A>::Type(a) >> typename NumberTraits::ToInteger<B>::Type(b)) & 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if USE_EMBEDDED_COMPILER
|
|
|
|
static constexpr bool compilable = false; /// TODO
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NameBitTest { static constexpr auto name = "bitTest"; };
|
|
|
|
using FunctionBitTest = FunctionBinaryArithmetic<BitTestImpl, NameBitTest>;
|
|
|
|
|
|
|
|
void registerFunctionBitTest(FunctionFactory & factory)
|
|
|
|
{
|
|
|
|
factory.registerFunction<FunctionBitTest>();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|