fixed overflow check

This commit is contained in:
myrrc 2020-12-17 22:10:33 +03:00
parent b428f8fcd8
commit fd1d24c928
2 changed files with 12 additions and 2 deletions

View File

@ -1041,7 +1041,11 @@ public:
return ResultDataType().createColumnConst(col_left_const->size(), toField(res));
}
col_res = ColVecResult::create(0, type.getScale());
if constexpr(IsDecimalNumber<ResultType>)
col_res = ColVecResult::create(0, type.getScale());
else
col_res = ColVecResult::create(0);
auto & vec_res = col_res->getData();
vec_res.resize(col_left_raw->size());

View File

@ -1,3 +1,4 @@
#include <type_traits>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionBinaryArithmetic.h>
#include <common/arithmeticOverflow.h>
@ -29,7 +30,12 @@ struct MultiplyImpl
template <typename Result = ResultType>
static inline bool apply(A a, B b, Result & c)
{
return common::mulOverflow(static_cast<Result>(a), b, c);
if constexpr(std::is_same_v<Result, float> || std::is_same_v<Result, double>)
{
c = static_cast<Result>(a) * b;
return false;
} else
return common::mulOverflow(static_cast<Result>(a), b, c);
}
#if USE_EMBEDDED_COMPILER