Skip to content

Commit a318191

Browse files
committed
Fixed corner-case rounding in int.__floordiv__
1 parent 8886403 commit a318191

File tree

1 file changed

+2
-2
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints

1 file changed

+2
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ int doLPiOvf(int left, PInt right) {
408408
try {
409409
return Math.floorDiv(left, right.intValueExact());
410410
} catch (ArithmeticException e) {
411-
return 0;
411+
return left < 0 == right.isNegative() ? 0 : -1;
412412
}
413413
}
414414

@@ -424,7 +424,7 @@ long doLPiOvf(long left, PInt right) {
424424
try {
425425
return Math.floorDiv(left, right.longValueExact());
426426
} catch (ArithmeticException e) {
427-
return 0;
427+
return left < 0 == right.isNegative() ? 0 : -1;
428428
}
429429
}
430430

0 commit comments

Comments
 (0)