mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
Adjustments
This commit is contained in:
parent
55c17ac93f
commit
d529db5498
@ -6,11 +6,11 @@
|
||||
#include <Common/NaNUtils.h>
|
||||
#include <DataTypes/NumberTraits.h>
|
||||
|
||||
|
||||
#if !defined(ARCADIA_BUILD)
|
||||
# include <Common/config.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
@ -90,20 +90,22 @@ struct DivideIntegralImpl
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Comparisons are not strict to avoid rounding issues when operand is implicitly casted to float.
|
||||
|
||||
if constexpr (std::is_floating_point_v<A>)
|
||||
if (isNaN(a) || a > std::numeric_limits<CastA>::max() || a < std::numeric_limits<CastA>::lowest())
|
||||
if (isNaN(a) || a >= std::numeric_limits<CastA>::max() || a <= std::numeric_limits<CastA>::lowest())
|
||||
throw Exception("Cannot perform integer division on infinite or too large floating point numbers",
|
||||
ErrorCodes::ILLEGAL_DIVISION);
|
||||
|
||||
if constexpr (std::is_floating_point_v<B>)
|
||||
if (isNaN(b) || b > std::numeric_limits<CastB>::max() || b < std::numeric_limits<CastB>::lowest())
|
||||
if (isNaN(b) || b >= std::numeric_limits<CastB>::max() || b <= std::numeric_limits<CastB>::lowest())
|
||||
throw Exception("Cannot perform integer division on infinite or too large floating point numbers",
|
||||
ErrorCodes::ILLEGAL_DIVISION);
|
||||
|
||||
auto res = checkedDivision(CastA(a), CastB(b));
|
||||
|
||||
if constexpr (std::is_floating_point_v<decltype(res)>)
|
||||
if (isNaN(res) || res > std::numeric_limits<Result>::max() || res < std::numeric_limits<Result>::lowest())
|
||||
if (isNaN(res) || res >= std::numeric_limits<Result>::max() || res <= std::numeric_limits<Result>::lowest())
|
||||
throw Exception("Cannot perform integer division, because it will produce infinite or too large number",
|
||||
ErrorCodes::ILLEGAL_DIVISION);
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
SELECT intDiv(9223372036854775807, 0.9998999834060669); -- { serverError 153 }
|
||||
SELECT intDiv(9223372036854775807, 1.); -- { serverError 153 }
|
||||
|
Loading…
Reference in New Issue
Block a user