This commit is contained in:
Alexey Milovidov 2020-11-05 12:26:51 +03:00
parent 22954cc123
commit 65aa226bcd

View File

@ -144,8 +144,17 @@ public:
T operator() (const Float64 & x) const
{
if constexpr (!std::is_floating_point_v<T>)
{
if (!isFinite(x))
{
/// When converting to bool it's ok (non-zero converts to true, NaN including).
if (std::is_same_v<T, bool>)
return true;
/// Conversion of infinite values to integer is undefined.
throw Exception("Cannot convert infinite value to integer type", ErrorCodes::CANNOT_CONVERT_TYPE);
}
}
if constexpr (std::is_same_v<Decimal256, T>)
return Int256(x);