- Notifications
You must be signed in to change notification settings - Fork157
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 ourterms of service andprivacy 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?
Uh oh!
There was an error while loading.Please reload this page.
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{ | ||
| pubfnpow<T,U>(mutbase:T,mutexp: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 removedT: Mul<T, Output = T> becauseOne needs it.
cuviper commentedNov 28, 2023
It is an unfortunate historical difference, but I think the |
mtshr commentedNov 29, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 in61d9a1b
Maybe I should have created an issue first. I apologize if discussing the idea here is quite inappropriate. |
Uh oh!
There was an error while loading.Please reload this page.
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 bea 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.