fixed div_floor sign handling
Jean-Philippe Bossuat jeanphilippe.bossuat@gmail.com
Wed, 08 Jan 2025 11:09:10 +0100
1 files changed,
1 insertions(+),
2 deletions(-)
jump to
M
math/src/num_bigint.rs
→
math/src/num_bigint.rs
@@ -1,5 +1,4 @@
use num_bigint::BigInt; -use num_bigint::Sign; use num_integer::Integer; use num_traits::{One, Signed, Zero};@@ -11,7 +10,7 @@
impl Div for BigInt { fn div_floor(&self, other: &Self) -> Self { let quo: BigInt = self / other; - if self.sign() == Sign::Minus { + if self.sign() != other.sign() { return quo - BigInt::one(); } return quo;