Skip to content

Commit 8dff979

Browse files
committed
Add Comments in TranslatorToZ3 for div and mod
1 parent 85d9a86 commit 8dff979

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

liquidjava-verifier/src/main/java/liquidjava/smt/TranslatorToZ3.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,14 @@ public Expr<?> makeDiv(Expr<?> eval, Expr<?> eval2) {
338338
return z3.mkFPDiv(z3.mkFPRoundNearestTiesToEven(), toFP(eval), toFP(eval2));
339339
if (eval instanceof RealExpr || eval2 instanceof RealExpr)
340340
return z3.mkDiv(toReal(eval), toReal(eval2));
341+
// Z3 integer division does not model Java's truncation toward zero for negative operands
341342
return z3.mkDiv((ArithExpr) eval, (ArithExpr) eval2);
342343
}
343344

344345
public Expr<?> makeMod(Expr<?> eval, Expr<?> eval2) {
345346
if (eval instanceof FPExpr || eval2 instanceof FPExpr)
346347
return z3.mkFPRem(toFP(eval), toFP(eval2));
348+
// Z3 integer modulo does not model Java's dividend-signed remainder for negative operands
347349
if (eval instanceof RealExpr || eval2 instanceof RealExpr)
348350
return z3.mkMod(toInt(eval), toInt(eval2));
349351
return z3.mkMod((IntExpr) eval, (IntExpr) eval2);

0 commit comments

Comments
 (0)