mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
fixed div_floor sign handling
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
use num_bigint::BigInt;
|
use num_bigint::BigInt;
|
||||||
use num_bigint::Sign;
|
|
||||||
use num_integer::Integer;
|
use num_integer::Integer;
|
||||||
use num_traits::{One, Signed, Zero};
|
use num_traits::{One, Signed, Zero};
|
||||||
|
|
||||||
@@ -11,7 +10,7 @@ pub trait Div {
|
|||||||
impl Div for BigInt {
|
impl Div for BigInt {
|
||||||
fn div_floor(&self, other: &Self) -> Self {
|
fn div_floor(&self, other: &Self) -> Self {
|
||||||
let quo: BigInt = self / other;
|
let quo: BigInt = self / other;
|
||||||
if self.sign() == Sign::Minus {
|
if self.sign() != other.sign() {
|
||||||
return quo - BigInt::one();
|
return quo - BigInt::one();
|
||||||
}
|
}
|
||||||
return quo;
|
return quo;
|
||||||
|
|||||||
Reference in New Issue
Block a user