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.
2 parents d717430 + edf3d28 commit 33b1471Copy full SHA for 33b1471
arby/include/arby/arby.hpp
@@ -378,7 +378,8 @@ namespace com::saxbophone::arby {
378
// multiply each digit from lhs with each digit from rhs
379
for (std::size_t l = 0; l < lhs._digits.size(); l++) {
380
for (std::size_t r = 0; r < rhs._digits.size(); r++) {
381
- OverflowType multiplication = lhs._digits[l] * rhs._digits[r];
+ // cast lhs to OverflowType to make sure both operands get promoted to avoid wrap-around overflow
382
+ OverflowType multiplication = (OverflowType)lhs._digits[l] * rhs._digits[r];
383
// create a new Uint with this intermediate result and add trailing places as needed
384
Uint intermediate = multiplication;
385
// we need to remap the indices as the digits are stored big-endian
0 commit comments