implicit const conversion

This commit is contained in:
Yatsishin Ilya 2021-03-09 17:31:54 +03:00
parent 71d0a50508
commit 71d745b4ec
4 changed files with 7 additions and 7 deletions

View File

@ -249,15 +249,15 @@ struct integer<Bits, Signed>::_impl
return;
}
const T alpha = t / max_int;
const T alpha = t / ((T) max_int);
if (alpha <= max_int)
if (alpha <= ((T) max_int))
self = static_cast<uint64_t>(alpha);
else // max(double) / 2^64 will surely contain less than 52 precision bits, so speed up computations.
set_multiplier<double>(self, alpha);
self *= max_int;
self += static_cast<uint64_t>(t - alpha * max_int); // += b_i
self += static_cast<uint64_t>(t - alpha * ((T) max_int)); // += b_i
}
constexpr static void wide_integer_from_bultin(integer<Bits, Signed>& self, double rhs) noexcept {
@ -275,7 +275,7 @@ struct integer<Bits, Signed>::_impl
"On your system long double has less than 64 precision bits,"
"which may result in UB when initializing double from int64_t");
if ((rhs > 0 && rhs < max_int) || (rhs < 0 && rhs > min_int))
if ((rhs > 0 && rhs < (double) max_int) || (rhs < 0 && rhs > (double) min_int))
{
self = static_cast<int64_t>(rhs);
return;

View File

@ -749,7 +749,7 @@ auto RandomishGenerator = [](auto i)
{
using T = decltype(i);
double sin_value = sin(static_cast<double>(i * i)) * i;
if (sin_value < std::numeric_limits<T>::lowest() || sin_value > std::numeric_limits<T>::max())
if (sin_value < std::numeric_limits<T>::lowest() || sin_value > (double) std::numeric_limits<T>::max())
return T{};
return T(sin_value);
};

View File

@ -212,7 +212,7 @@ convertToDecimalImpl(const typename FromDataType::FieldType & value, UInt32 scal
static constexpr Int128 min_int128 = minInt128();
static constexpr Int128 max_int128 = maxInt128();
if (out <= static_cast<ToNativeType>(min_int128) || out >= static_cast<ToNativeType>(max_int128))
if (out <= static_cast<ToNativeType>(min_int128) || out >= (float) static_cast<ToNativeType>(max_int128))
{
if constexpr (throw_exception)
throw Exception(std::string(ToDataType::family_name) + " convert overflow. Float is out of Decimal range",

View File

@ -105,7 +105,7 @@ struct DivideIntegralImpl
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 >= (double) 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);