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

Add constexpr shift_right mp helper #4008

Merged
merged 1 commit into from
Apr 12, 2024
Merged

Add constexpr shift_right mp helper #4008

merged 1 commit into from
Apr 12, 2024

Conversation

randombit
Copy link
Owner

No description provided.

@coveralls
Copy link

Coverage Status

coverage: 92.02% (-0.007%) from 92.027%
when pulling 89d0d1b on jack/mp-shift-right
into 3801b0a on master.

Comment on lines +861 to +866
W carry = 0;
for(size_t i = 0; i != N; ++i) {
const W w = x[N - 1 - i];
x[N - 1 - i] = (w >> S) | carry;
carry = w << (WordInfo<W>::bits - S);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we'd let the loop run backwards from i = N - 1 to i >0, would that make the indices easier to understand?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I agree the indices would be clearer going in the other direction. But for whatever reason I find the pattern of consistently mapping from i \in [0..N) to an action on that i easier to follow.

@randombit randombit merged commit 7113fb4 into master Apr 12, 2024
43 checks passed
@randombit randombit deleted the jack/mp-shift-right branch April 12, 2024 13:11
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.

3 participants