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 Pow for BigUint and BigInt #29

Closed
clarfonthey opened this issue Feb 27, 2018 · 12 comments
Closed

Implement Pow for BigUint and BigInt #29

clarfonthey opened this issue Feb 27, 2018 · 12 comments

Comments

@clarfonthey
Copy link
Contributor

clarfonthey commented Feb 27, 2018

See rust-num/num-traits#38 for details on this trait.

@vks
Copy link
Contributor

vks commented Jul 2, 2018

Is this necessary given that it is implemented in num-traits now?

@cuviper
Copy link
Member

cuviper commented Jul 2, 2018

What do you mean? Pow is defined in num-traits, and implemented for the primitive types, but we need to implement it here for bigints.

@vks
Copy link
Contributor

vks commented Jul 3, 2018

I thought num-traits provided a generic implementation, but apparently that is not the case.

@thomwiggers
Copy link
Contributor

Let's see if I can do this – I need in anyhow.

@vks
Copy link
Contributor

vks commented Jul 5, 2018

@cuviper I found it: num_traits::pow. This should work for BigInt as well. (Something like powm in this num-integer PR would probably be more efficient though.)

@cuviper
Copy link
Member

cuviper commented Jul 5, 2018

I found it: num_traits::pow. This should work for BigInt as well.

Yes, but that only works by-value with a usize exponent. The Pow trait is more flexible.

(Something like powm in this num-integer PR would probably be more efficient though.)

Modular pow is a different thing though -- and FWIW we do have inherent modpow methods here.

@vks
Copy link
Contributor

vks commented Jul 16, 2018

Yes, but that only works by-value with a usize exponent. The Pow trait is more flexible.

A u32 exponent should be enough, and by-value is more efficient.

bors bot added a commit that referenced this issue Aug 4, 2018
54: Implement Pow for BigUint and BigInt r=cuviper a=thomwiggers

Implements #29

Co-authored-by: Thom Wiggers <thom@thomwiggers.nl>
@windelbouwman
Copy link

I'm interested in this pow function, will there be a new release of this crate at some point containing pow, or is there work left to do?

@cuviper
Copy link
Member

cuviper commented Nov 3, 2018

Thanks for the reminder - I've published num-bigint 0.2.1.

@cuviper cuviper closed this as completed Nov 3, 2018
@peterbraden
Copy link

Still not updated in num? I get:
Updating crates.io index Downloading num v0.2.0 Downloading num-bigint v0.2.1 Downloading num-rational v0.2.1 Compiling num-integer v0.1.39 Compiling num-iter v0.1.37 Compiling num-complex v0.2.1 Compiling num-bigint v0.2.1 Compiling num-rational v0.2.1 Compiling num-bigint v0.1.40 error[E0277]: the trait boundbiguint::BigUint: num_traits::Num is not satisfied

@cuviper
Copy link
Member

cuviper commented Dec 11, 2018

@peterbraden Somehow you have both new and old, Compiling num-bigint v0.2.1 and Compiling num-bigint v0.1.40. Only 0.2.1 implements Pow.

Your output doesn't show which num-traits you're compiling, but your two num-bigints will also require num-traits 0.2 and 0.1. That would be OK for Num (your error message) if the latter were 0.1.43, as that just re-exports the 0.2 versions. Alternatively, num-bigint 0.1.41 started using num-traits 0.2 as well, but it still won't have Pow.

@peterbraden
Copy link

I did a cargo update and all worked, not sure how I got into that state, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants