Skip to content

Generate random big integers within a range #9133

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

Merged
merged 1 commit into from
Sep 18, 2013

Conversation

dcrewi
Copy link
Contributor

@dcrewi dcrewi commented Sep 12, 2013

No description provided.

@dcrewi
Copy link
Contributor Author

dcrewi commented Sep 12, 2013

Maybe @huonw would want to take a look at this, considering it's an extension of a previous PR?

if self.data.len() == 0 { return 0; }
let mut bits = (self.data.len()-1) * BigDigit::bits;
let mut top_digit = self.data[self.data.len()-1];
while top_digit != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I believe this can be done with BigDigit::bits - top_digit.leading_zeros(); leading_zeros comes from std::num::BitCount if you need to import it.

@alexcrichton
Copy link
Member

As one final small nit, would you mind squashing these commits all into one? Also feel free to comment when done, because sadly github doesn't send any notifications when you rebase the branch. Thanks!

@dcrewi
Copy link
Contributor Author

dcrewi commented Sep 17, 2013

Squashed rebase has been pushed.

@dcrewi dcrewi closed this Sep 17, 2013
@huonw
Copy link
Member

huonw commented Sep 17, 2013

Did you close this on purpose? It hasn't landed yet.

@dcrewi
Copy link
Contributor Author

dcrewi commented Sep 18, 2013

No it wasn't on purpose. I think github did it automatically when I deleted my branch on github.

@dcrewi dcrewi reopened this Sep 18, 2013
@dcrewi
Copy link
Contributor Author

dcrewi commented Sep 18, 2013

I also noticed that I forgot to make .bits() public.

@bors bors merged commit af72e41 into rust-lang:master Sep 18, 2013
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.

4 participants