Skip to content

Commit 714843d

Browse files
committed
replace manual implementation with carrying_mul_add
1 parent 4b94758 commit 714843d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

library/core/src/num/bignum.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ macro_rules! impl_full_ops {
3838
fn full_mul_add(self, other: $ty, other2: $ty, carry: $ty) -> ($ty, $ty) {
3939
// This cannot overflow;
4040
// the output is between `0` and `2^nbits * (2^nbits - 1)`.
41-
let v = (self as $bigty) * (other as $bigty) + (other2 as $bigty) +
42-
(carry as $bigty);
43-
((v >> <$ty>::BITS) as $ty, v as $ty)
41+
let (lo, hi) = self.carrying_mul_add(other, other2, carry);
42+
(hi, lo)
4443
}
4544

4645
fn full_div_rem(self, other: $ty, borrow: $ty) -> ($ty, $ty) {

0 commit comments

Comments
 (0)