1#include <Functions/FunctionNumericPredicate.h>
2#include <Functions/FunctionFactory.h>
3#include <ext/bit_cast.h>
4#include <type_traits>
5
6
7namespace DB
8{
9
10struct IsInfiniteImpl
11{
12 static constexpr auto name = "isInfinite";
13 template <typename T>
14 static bool execute(const T t)
15 {
16 if constexpr (std::is_same_v<T, float>)
17 return (ext::bit_cast<uint32_t>(t)
18 & 0b01111111111111111111111111111111)
19 == 0b01111111100000000000000000000000;
20 else if constexpr (std::is_same_v<T, double>)
21 return (ext::bit_cast<uint64_t>(t)
22 & 0b0111111111111111111111111111111111111111111111111111111111111111)
23 == 0b0111111111110000000000000000000000000000000000000000000000000000;
24 else
25 {
26 (void)t;
27 return false;
28 }
29 }
30};
31
32using FunctionIsInfinite = FunctionNumericPredicate<IsInfiniteImpl>;
33
34
35void registerFunctionIsInfinite(FunctionFactory & factory)
36{
37 factory.registerFunction<FunctionIsInfinite>();
38}
39
40}
41