Changed semantic of intDiv, intDivOrZero functions for floating point arguments [#METR-19446].

This commit is contained in:
Alexey Milovidov 2016-08-19 06:17:53 +03:00
parent 06bcc34be2
commit e960efd5e6
4 changed files with 15 additions and 3 deletions

View File

@ -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;
}
};

View File

@ -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;
};

View File

@ -0,0 +1,6 @@
2
2
2
2
3
3

View File

@ -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);