-
Notifications
You must be signed in to change notification settings - Fork 153
Generic exp for pow and checked_pow #300
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
base: master
Are you sure you want to change the base?
Conversation
| (prim_int $t:ty) => { | ||
| pow_impl!($t, u8); | ||
| pow_impl!($t, u16); | ||
| pow_impl!($t, u32, u32, <$t>::pow); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utilizes the default implementation of pow for exp with u32
| if exp == 0 { | ||
| pub fn pow<T, U>(mut base: T, mut exp: U) -> T | ||
| where | ||
| T: Clone + One, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed T: Mul<T, Output = T> because One needs it.
|
It is an unfortunate historical difference, but I think the |
|
Thank you for taking a look.
I am sorry that my English ability is not sufficient, but am I right in interpreting you think it is too much to change
I know others may have a interest in one (ref #254) and I am not against the idea to add one. I consider making a pull request once the idea of generalizing exp is accepted, for I do not want to yield another FIXME. Lines 26 to 29 in 61d9a1b
Maybe I should have created an issue first. I apologize if discussing the idea here is quite inappropriate. |
Due to the
expbeingusize, the current implementation has been inconsistent with core implementation ofpowandchecked_powtakingu32forexp. This has also inhibited implementation of somePow<u*>for primitive integers.This pull request generalizes
expto use unsigned primitive integer for the sake of the implementation of lackingPow<u*>and more importantly, I guess, the consistency with corepowandchecked_powutilizingu32, for the use of architecture dependently sized type, namelyusizehere, for arithmetic function does not sound reasonable.Although this change should be a minor change as
usizedoes implementsPrimInt + Unsigned, please note that the existing crate depending on the functions in question may come to be in need of adding some type notation, as {integer} is assumed to bei32.