Skip to content

Commit 10c60d0

Browse files
committed
Check signed lhs < rhs
1 parent eb83524 commit 10c60d0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

include/boost/int128/detail/int128_imp.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,12 @@ constexpr int128_t operator/(const int128_t lhs, const SignedInteger rhs) noexce
26062606
const auto negative_res {static_cast<bool>((lhs.high < 0) ^ (rhs < 0))};
26072607
const auto abs_rhs {rhs < 0 ? -rhs : rhs};
26082608
const auto abs_lhs {abs(lhs)};
2609+
2610+
if (abs_lhs < abs_rhs)
2611+
{
2612+
return {0, 0};
2613+
}
2614+
26092615
detail::one_word_div(abs_lhs, static_cast<eval_type>(abs_rhs), quotient);
26102616

26112617
return negative_res ? -quotient : quotient;

0 commit comments

Comments
 (0)