mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Fix error
This commit is contained in:
parent
cd7a8d1560
commit
75ac3c96df
@ -26,7 +26,6 @@ bool lessOp(A a, B b)
|
||||
return a < b;
|
||||
|
||||
/// anything vs NaN
|
||||
if constexpr (std::is_floating_point_v<A> || std::is_floating_point_v<B>)
|
||||
if (isNaN(a) || isNaN(b))
|
||||
return false;
|
||||
|
||||
@ -40,10 +39,10 @@ bool lessOp(A a, B b)
|
||||
/// different signedness
|
||||
|
||||
if constexpr (is_signed_v<A> && !is_signed_v<B>)
|
||||
return a < 0 || static_cast<B>(a) < b;
|
||||
return a < 0 || static_cast<make_unsigned_t<A>>(a) < b;
|
||||
|
||||
if constexpr (!is_signed_v<A> && is_signed_v<B>)
|
||||
return b >= 0 && a < static_cast<A>(b);
|
||||
return b >= 0 && a < static_cast<make_unsigned_t<B>>(b);
|
||||
}
|
||||
|
||||
/// int vs float
|
||||
@ -176,8 +175,8 @@ inline bool NO_SANITIZE_UNDEFINED convertNumeric(From value, To & result)
|
||||
}
|
||||
}
|
||||
|
||||
if (accurate::greaterOp(value, std::numeric_limits<To>::max())
|
||||
|| accurate::greaterOp(std::numeric_limits<To>::lowest(), value))
|
||||
if (greaterOp(value, std::numeric_limits<To>::max())
|
||||
|| lessOp(value, std::numeric_limits<To>::lowest()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -53,6 +53,10 @@ GTEST_TEST(AccurateComparison, Tests)
|
||||
|
||||
ASSERT_TRUE(accurate::equalsOp(static_cast<Float32>(9223372036854775808ULL), static_cast<Float64>(9223372036854775808ULL)));
|
||||
|
||||
/// Integers
|
||||
ASSERT_TRUE(accurate::lessOp(static_cast<UInt8>(255), 300));
|
||||
|
||||
|
||||
/* Float32 f = static_cast<Float32>(9223372000000000000ULL);
|
||||
UInt64 u = static_cast<UInt64>(9223372000000000000ULL);
|
||||
DecomposedFloat32 components(f);
|
||||
|
Loading…
Reference in New Issue
Block a user