From be87ac6ae75a9d6d59b189980a0363a0236d85b0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bossuat Date: Wed, 8 Jan 2025 11:09:10 +0100 Subject: [PATCH] fixed div_floor sign handling --- math/src/num_bigint.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/math/src/num_bigint.rs b/math/src/num_bigint.rs index 84a2312..371281f 100644 --- a/math/src/num_bigint.rs +++ b/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 @@ pub trait Div { 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;