diff --git a/changes/v0.12.1 b/changes/v0.12.1 index 140be3c..60c925b 100644 --- a/changes/v0.12.1 +++ b/changes/v0.12.1 @@ -1,3 +1,4 @@ - fix midpoint method - fix posoverflow being returned instead of invaliddigit for parsing ints -- change debug implementation of parseinterror \ No newline at end of file +- change debug implementation of parseinterror +- fix num-integer lcm implementation for signed ints \ No newline at end of file diff --git a/src/bint/numtraits.rs b/src/bint/numtraits.rs index c71a8f5..9114711 100644 --- a/src/bint/numtraits.rs +++ b/src/bint/numtraits.rs @@ -213,7 +213,7 @@ macro_rules! numtraits { if self.is_zero() || other.is_zero() { Self::ZERO } else { - self.div_floor(&self.gcd(other)) * *other + (self.div_floor(&self.gcd(other)) * *other).abs() } } diff --git a/src/int/numtraits.rs b/src/int/numtraits.rs index 033c165..3c2333a 100644 --- a/src/int/numtraits.rs +++ b/src/int/numtraits.rs @@ -511,7 +511,8 @@ macro_rules! tests { #[allow(unused_comparisons)] let cond = a.checked_mul(b).is_none() || (a < 0 && a == <$int>::MIN) || (b < 0 && b == <$int>::MIN); // lcm(a, b) <= a * b cond - } + }, + cases: [(ref &(1 as $int), ref &(-1i8 as $int))] } test_bignum! { function: <$int as Integer>::gcd(a: ref &$int, b: ref &$int),