mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Changed semantic of intDiv, intDivOrZero functions for floating point arguments [#METR-19446].
This commit is contained in:
parent
06bcc34be2
commit
e960efd5e6
@ -174,7 +174,7 @@ struct DivideIntegralImpl
|
||||
static inline Result apply(A a, B b)
|
||||
{
|
||||
throwIfDivisionLeadsToFPE(a, b);
|
||||
return static_cast<Result>(a) / b;
|
||||
return a / b;
|
||||
}
|
||||
};
|
||||
|
||||
@ -186,7 +186,7 @@ struct DivideIntegralOrZeroImpl
|
||||
template <typename Result = ResultType>
|
||||
static inline Result apply(A a, B b)
|
||||
{
|
||||
return unlikely(divisionLeadsToFPE(a, b)) ? 0 : static_cast<Result>(a) / b;
|
||||
return unlikely(divisionLeadsToFPE(a, b)) ? 0 : a / b;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -134,7 +134,7 @@ template <typename A, typename B> struct ResultOfIntegerDivision
|
||||
{
|
||||
typedef typename Construct<
|
||||
typename boost::mpl::or_<typename Traits<A>::Sign, typename Traits<B>::Sign>::type,
|
||||
typename boost::mpl::or_<typename Traits<A>::Floatness, typename Traits<B>::Floatness>::type,
|
||||
Integer,
|
||||
typename Traits<A>::Bits>::Type Type;
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
@ -0,0 +1,6 @@
|
||||
SELECT intDiv(10, 4);
|
||||
SELECT intDiv(10., 4);
|
||||
SELECT intDiv(10, 4.);
|
||||
SELECT intDiv(10., 4.);
|
||||
SELECT intDiv(1, 0.3);
|
||||
SELECT intDiv(1.0, 0.3);
|
Loading…
Reference in New Issue
Block a user