2018-09-08 22:04:39 +00:00
|
|
|
#include <Functions/FunctionNumericPredicate.h>
|
|
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-09-07 18:00:37 +00:00
|
|
|
namespace
|
|
|
|
{
|
2018-09-08 22:04:39 +00:00
|
|
|
|
|
|
|
struct IsInfiniteImpl
|
|
|
|
{
|
|
|
|
static constexpr auto name = "isInfinite";
|
|
|
|
template <typename T>
|
|
|
|
static bool execute(const T t)
|
|
|
|
{
|
|
|
|
if constexpr (std::is_same_v<T, float>)
|
2022-11-04 15:52:48 +00:00
|
|
|
return (std::bit_cast<uint32_t>(t)
|
2018-09-08 22:04:39 +00:00
|
|
|
& 0b01111111111111111111111111111111)
|
|
|
|
== 0b01111111100000000000000000000000;
|
|
|
|
else if constexpr (std::is_same_v<T, double>)
|
2022-11-04 15:52:48 +00:00
|
|
|
return (std::bit_cast<uint64_t>(t)
|
2018-09-08 22:04:39 +00:00
|
|
|
& 0b0111111111111111111111111111111111111111111111111111111111111111)
|
|
|
|
== 0b0111111111110000000000000000000000000000000000000000000000000000;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
(void)t;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
using FunctionIsInfinite = FunctionNumericPredicate<IsInfiniteImpl>;
|
|
|
|
|
2020-09-07 18:00:37 +00:00
|
|
|
}
|
2018-09-08 22:04:39 +00:00
|
|
|
|
2022-07-04 07:01:39 +00:00
|
|
|
REGISTER_FUNCTION(IsInfinite)
|
2018-09-08 22:04:39 +00:00
|
|
|
{
|
|
|
|
factory.registerFunction<FunctionIsInfinite>();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|