From 714843dc57f58e144862bd3f34416e1dd6b15167 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Tue, 14 Oct 2025 06:13:22 +0000 Subject: [PATCH] replace manual implementation with carrying_mul_add --- library/core/src/num/bignum.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/core/src/num/bignum.rs b/library/core/src/num/bignum.rs index f21fe0b4438fb..33b1e8cb56db2 100644 --- a/library/core/src/num/bignum.rs +++ b/library/core/src/num/bignum.rs @@ -38,9 +38,8 @@ macro_rules! impl_full_ops { fn full_mul_add(self, other: $ty, other2: $ty, carry: $ty) -> ($ty, $ty) { // This cannot overflow; // the output is between `0` and `2^nbits * (2^nbits - 1)`. - let v = (self as $bigty) * (other as $bigty) + (other2 as $bigty) + - (carry as $bigty); - ((v >> <$ty>::BITS) as $ty, v as $ty) + let (lo, hi) = self.carrying_mul_add(other, other2, carry); + (hi, lo) } fn full_div_rem(self, other: $ty, borrow: $ty) -> ($ty, $ty) {