We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
BigInt::mul
1 parent 7457e2c commit 9baa414Copy full SHA for 9baa414
libc/src/__support/UInt.h
@@ -262,15 +262,13 @@ struct BigInt {
262
// Returns the carry value produced by the multiplication operation.
263
LIBC_INLINE constexpr WordType mul(WordType x) {
264
BigInt<2 * WORD_SIZE, Signed, WordType> partial_sum(0);
265
- WordType carry = 0;
266
for (size_t i = 0; i < WORD_COUNT; ++i) {
267
NumberPair<WordType> prod = full_mul(val[i], x);
268
BigInt<2 * WORD_SIZE, Signed, WordType> tmp({prod.lo, prod.hi});
269
- carry += partial_sum.add(tmp);
+ const WordType carry = partial_sum.add(tmp);
270
val[i] = partial_sum.val[0];
271
partial_sum.val[0] = partial_sum.val[1];
272
partial_sum.val[1] = carry;
273
- carry = 0;
274
}
275
return partial_sum.val[1];
276
0 commit comments