mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Make it more correct
This commit is contained in:
parent
40e73b9134
commit
ae67ea3ab3
@ -66,7 +66,8 @@ struct DivideIntegralImpl
|
||||
/// Otherwise overflow may occur due to integer promotion. Example: int8_t(-1) / uint64_t(2).
|
||||
/// NOTE: overflow is still possible when dividing large signed number to large unsigned number or vice-versa. But it's less harmful.
|
||||
if constexpr (is_integral_v<A> && is_integral_v<B> && (is_signed_v<A> || is_signed_v<B>))
|
||||
return checkedDivision(std::make_signed_t<A>(a), std::make_signed_t<B>(b));
|
||||
return checkedDivision(std::make_signed_t<A>(a),
|
||||
sizeof(A) > sizeof(B) ? std::make_signed_t<A>(b) : std::make_signed_t<B>(b));
|
||||
else
|
||||
return checkedDivision(a, b);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user