3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

fix semantics of check-int64 div operation to align with smtlib semantics

This commit is contained in:
Nikolaj Bjorner 2025-01-29 04:29:38 -08:00
parent 30d72f79ac
commit ab43d2dcf1
2 changed files with 15 additions and 0 deletions

View file

@ -300,6 +300,16 @@ template<bool CHECK>
inline checked_int64<CHECK> div(checked_int64<CHECK> const& a, checked_int64<CHECK> const& b) {
checked_int64<CHECK> result(a);
result /= b;
if (a < 0) {
checked_int64<CHECK> r(a);
r %= b;
if (r != 0) {
if (b < 0)
result += 1;
else
result -= 1;
}
}
return result;
}