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

Implement operators with 128bits #64

Merged
merged 2 commits into from
Aug 11, 2018
Merged

Conversation

dignifiedquire
Copy link
Contributor

@dignifiedquire dignifiedquire mentioned this pull request Jul 23, 2018
2 tasks
@cuviper
Copy link
Member

cuviper commented Aug 7, 2018

Please rebase on the rebased+merged #63.

@dignifiedquire
Copy link
Contributor Author

Please rebase on the rebased+merged #63.

@cuviper done

Copy link
Member

@cuviper cuviper left a comment

Choose a reason for hiding this comment

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

Nice job! Just left a few small requests.

Despite all the macros, there's still a lot of copy-paste with only slight edits, but that's not your fault. Maybe someday we'll figure out how to refactor all of this with less duplication...

if other != 0 {
if self.data.len() == 0 {
self.data.push(0);
}

let carry = __add2(&mut self.data, &[other]);
let carry = __add2(&mut self.data, &[other as BigDigit]);
Copy link
Member

Choose a reason for hiding this comment

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

Let's use From or Into here, just to future-proof that this is never lossy, e.g. &[other.into()]

(ditto for all of the similar places with a lossless cast as BigDigit.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there are a bunch of places in here already that used as instead of from/into. Should I just convert all of them, or is there any potential drawback?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, we can leave that for future cleanup, but let's at least do that before (or during) the BigDigit upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

created a tracking issue for this: #66

self.data.push(0);
}
__add2(&mut self.data, &[d, c, b, a])
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Let's debug_assert!(b > 0) here, as a self-check/documentation that smaller values were caught as u64 already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

src/biguint.rs Outdated
bits += big_digit::BITS;
}

println!("{:?} -> {}", self, ret);
Copy link
Member

Choose a reason for hiding this comment

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

Stray debug print?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@cuviper
Copy link
Member

cuviper commented Aug 11, 2018

Thanks!

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 11, 2018

👎 Rejected by code reviews

@cuviper
Copy link
Member

cuviper commented Aug 11, 2018

bors r+

bors bot added a commit that referenced this pull request Aug 11, 2018
64: Implement operators with 128bits r=cuviper a=dignifiedquire

- Depends on #63 
- This is the second part to #40 

Co-authored-by: dignifiedquire <dignifiedquire@gmail.com>
@bors
Copy link
Contributor

bors bot commented Aug 11, 2018

Build succeeded

@bors bors bot merged commit 1968390 into rust-num:master Aug 11, 2018
bors bot added a commit that referenced this pull request Jan 13, 2020
62: Finish i128 support r=cuviper a=dignifiedquire

Depends on #63 and #64 

Implements `BigDigit = u64` ~~behind a feature flag `u64_digit`~~ for all 64-bit targets with `u128`.

TODOs
- [x] find a way to make the new methods that take `BigDigit`s for constructing `BigUint`s private
- [x] Fix `modpow`, the last broken test.

Closes #40 


Co-authored-by: dignifiedquire <dignifiedquire@gmail.com>
Co-authored-by: Josh Stone <cuviper@gmail.com>
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

2 participants