We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 86fcc97 commit 50c119aCopy full SHA for 50c119a
2 files changed
tests/snippets/ints.py
@@ -64,6 +64,10 @@
64
assert (2).__pow__(3.0) == NotImplemented
65
assert (2).__rpow__(3.0) == NotImplemented
66
67
+assert 10 // 4 == 2
68
+assert -10 // 4 == -3
69
+assert 10 // -4 == -3
70
+assert -10 // -4 == 2
71
72
assert int() == 0
73
assert int("101", 2) == 5
vm/src/obj/objint.rs
@@ -260,7 +260,8 @@ impl PyInt {
260
if objtype::isinstance(&other, &vm.ctx.int_type()) {
261
let v2 = get_value(&other);
262
if *v2 != BigInt::zero() {
263
- Ok(vm.ctx.new_int((&self.value) / v2))
+ let modulo = (&self.value % v2 + v2) % v2;
264
+ Ok(vm.ctx.new_int((&self.value - modulo) / v2))
265
} else {
266
Err(vm.new_zero_division_error("integer floordiv by zero".to_string()))
267
}
0 commit comments