Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change order of evaluation to avoid underflow error #575

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

mdvillagra
Copy link
Contributor

@mdvillagra mdvillagra commented Sep 25, 2023

Change order of evaluation to avoid underflow error

Description

When the number of limbs in an unsigned integer is 1, like in the babybear field, the line

let index = 2 * i - NUM_LIMBS + 1;

panicks. This is because all variables are usize and when i=0 then NUM_LIMBS is subtracted and gives -1.

To solve the problem mentioned above is suffices to change the evaluation order.

Type of change

  • Bug fix

@mdvillagra mdvillagra requested review from schouhy, ajgara and a team as code owners September 25, 2023 12:58
@codecov-commenter
Copy link

Codecov Report

Merging #575 (8553708) into main (da688cd) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #575   +/-   ##
=======================================
  Coverage   95.50%   95.50%           
=======================================
  Files         112      112           
  Lines       19006    19006           
=======================================
  Hits        18152    18152           
  Misses        854      854           
Files Changed Coverage Δ
math/src/unsigned_integer/element.rs 97.43% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@MauroToscano
Copy link
Collaborator

LGTM. Thanks for the fix

Copy link
Contributor

@pablodeymo pablodeymo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@MauroToscano MauroToscano added this pull request to the merge queue Sep 25, 2023
Merged via the queue into lambdaclass:main with commit 8e0438a Sep 25, 2023
6 checks passed
@mdvillagra mdvillagra deleted the unsigned-integer-bug-fix branch September 25, 2023 14:49
PatStiles pushed a commit to PatStiles/lambdaworks that referenced this pull request Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants