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

Constant space from base conversions #293

Merged
merged 7 commits into from
Aug 13, 2023
Merged

Constant space from base conversions #293

merged 7 commits into from
Aug 13, 2023

Conversation

recmo
Copy link
Owner

@recmo recmo commented Aug 3, 2023

Motivation

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog

@codecov
Copy link

codecov bot commented Aug 3, 2023

Codecov Report

Patch coverage: 72.58% and project coverage change: -0.27% ⚠️

Comparison is base (1b14a40) 82.85% compared to head (bbe5bef) 82.59%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #293      +/-   ##
==========================================
- Coverage   82.85%   82.59%   -0.27%     
==========================================
  Files          53       53              
  Lines        5681     5704      +23     
==========================================
+ Hits         4707     4711       +4     
- Misses        974      993      +19     
Files Changed Coverage Δ
src/algorithms/mod.rs 100.00% <ø> (ø)
src/base_convert.rs 87.61% <67.30%> (-6.02%) ⬇️
src/algorithms/mul.rs 100.00% <100.00%> (+0.42%) ⬆️
src/aliases.rs 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

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

src/base_convert.rs Outdated Show resolved Hide resolved
@recmo recmo marked this pull request as ready for review August 3, 2023 17:27
@recmo recmo requested a review from prestwich as a code owner August 3, 2023 17:27
@prestwich
Copy link
Collaborator

approach is good, i think we still disagree on the behavior wrt infinite iterators

@recmo
Copy link
Owner Author

recmo commented Aug 7, 2023

This is mostly orthogonal to how long iterators are handled and should make things strictly better. Ready for review.

I mostly wrote it because abusing the stack to reverse a list seemed like a bad idea.

/// Computes `lhs *= a` and returns the carry.
pub fn mul_nx1(lhs: &mut [u64], a: u64) -> u64 {
let mut carry = 0;
for lhs in lhs.iter_mut() {
Copy link
Collaborator

@prestwich prestwich Aug 8, 2023

Choose a reason for hiding this comment

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

if lhs is empty this will return 0. is this intended, or should it return a? my belief is that a 0-byte uint always represents the number 0, so carry on a mul is always 0.

Copy link
Owner Author

Choose a reason for hiding this comment

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

my belief is that a 0-byte uint always represents the number 0

This is correct. See for example U0::ZERO. (This is also the reason why no Uint::ONE can exits)

@prestwich prestwich merged commit 55c5411 into main Aug 13, 2023
11 of 13 checks passed
@prestwich prestwich deleted the remco/base-to branch August 13, 2023 20: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.

2 participants