mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
fixed div_floor sign handling
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user