Skip to content

Fix remainder sign in Int floored division - #1409

Open
1ooper wants to merge 1 commit into
RustCrypto:masterfrom
1ooper:fix/int-floor-remainder-sign
Open

1ooper wants to merge 1 commit into
RustCrypto:masterfrom
1ooper:fix/int-floor-remainder-sign

Conversation

@1ooper

@1ooper 1ooper commented Nov 23, 2026

Copy link
Copy Markdown

Int::checked_div_rem_floor and Int::checked_div_rem_floor_vartime return a remainder with the wrong sign when the dividend is negative For example, dividing -8 by 3 returns (-3, -1), but -3 * 3 + (-1) = -10. It shoud return (-3, 1) i.e. -3 * 3 + 1 = -8.

Use the divisor’s sign (rhs_sgn) for the remainder so that a = q * b + r holds. The quotient still uses opposing_signs.

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.84%. Comparing base (8401486) to head (5cba7ca).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1409      +/-   ##
==========================================
+ Coverage   91.76%   91.84%   +0.07%     
==========================================
  Files         190      190              
  Lines       23503    23511       +8     
==========================================
+ Hits        21568    21593      +25     
+ Misses       1935     1918      -17     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

1 participant