mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
9c066e964d
Converted usage of CH-custom bit_cast to std::bit_cast if possible, i.e. when sizeof(From) == sizeof(To). (The CH-custom bit_cast is able to deal with sizeof(From) != sizeof(To).) Motivation for this came from #42847 where it is not clear how the internal bit_cast should behave on big endian systems, so we better avoid that situation as much as possible.
43 lines
1010 B
C++
43 lines
1010 B
C++
#include <Functions/FunctionNumericPredicate.h>
|
|
#include <Functions/FunctionFactory.h>
|
|
#include <type_traits>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
namespace
|
|
{
|
|
|
|
struct IsInfiniteImpl
|
|
{
|
|
static constexpr auto name = "isInfinite";
|
|
template <typename T>
|
|
static bool execute(const T t)
|
|
{
|
|
if constexpr (std::is_same_v<T, float>)
|
|
return (std::bit_cast<uint32_t>(t)
|
|
& 0b01111111111111111111111111111111)
|
|
== 0b01111111100000000000000000000000;
|
|
else if constexpr (std::is_same_v<T, double>)
|
|
return (std::bit_cast<uint64_t>(t)
|
|
& 0b0111111111111111111111111111111111111111111111111111111111111111)
|
|
== 0b0111111111110000000000000000000000000000000000000000000000000000;
|
|
else
|
|
{
|
|
(void)t;
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
|
|
using FunctionIsInfinite = FunctionNumericPredicate<IsInfiniteImpl>;
|
|
|
|
}
|
|
|
|
REGISTER_FUNCTION(IsInfinite)
|
|
{
|
|
factory.registerFunction<FunctionIsInfinite>();
|
|
}
|
|
|
|
}
|