Skip to content

Commit

Permalink
fix lcm
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacholt100 committed Jan 1, 2025
1 parent 82e1fdb commit 8744acc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion changes/v0.12.1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- fix midpoint method
- fix posoverflow being returned instead of invaliddigit for parsing ints
- change debug implementation of parseinterror
- change debug implementation of parseinterror
- fix num-integer lcm implementation for signed ints
2 changes: 1 addition & 1 deletion src/bint/numtraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/int/numtraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 8744acc

Please sign in to comment.