Skip to content

Commit

Permalink
changed order of evaluation to avoid underflow (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdvillagra authored Sep 25, 2023
1 parent 0a299a7 commit 8e0438a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion math/src/unsigned_integer/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ impl<const NUM_LIMBS: usize> UnsignedInteger<NUM_LIMBS> {
while i > 0 {
i -= 1;
if NUM_LIMBS - 1 <= i * 2 {
let index = 2 * i - NUM_LIMBS + 1;
let index = 2 * i + 1 - NUM_LIMBS;
let cs = lo.limbs[index] as u128 + a.limbs[i] as u128 * a.limbs[i] as u128 + c;
c = cs >> 64;
lo.limbs[index] = cs as u64;
Expand Down

0 comments on commit 8e0438a

Please sign in to comment.