arnaucube
arnaucube/poulpyPublic Self-hosted repository
fixed div_floor sign handling
Jean-Philippe Bossuat jeanphilippe.bossuat@gmail.com
Wed, 08 Jan 2025 11:09:10 +0100
commit

be87ac6ae75a9d6d59b189980a0363a0236d85b0

parent

160e7a33da29b4e58ac39d41edb7a09092e03ecd

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;