You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It does not really make sense that the exponent is a pointer-sized uint. This makes this function unnecessarily platform-dependent.
Also, it is awkward to use with BigInt as an exponent. (This mainly an ergonomic issue, as a uint should be large enough to store any reasonable exponent.)
I think it would be better to have a signature like
pubfnpow<T:One + Mul<T,T>,U:One + Zero + Add<U,U> + Div<U,U>>(base:T,exp:U) -> T
(Note that pow currently uses some bitwise operations for efficiency, the proposed type constraints do not reflect that.)
Alternatively, to keep it simple the exponent could just be a constant-size unsigned integer (u32 should be sufficient [1]).
[1] pow(1.1, pow(2, 32)) ~= pow(10, 177780229)
The text was updated successfully, but these errors were encountered:
Right now
pow
has the following signature:It does not really make sense that the exponent is a pointer-sized
uint
. This makes this function unnecessarily platform-dependent.Also, it is awkward to use with
BigInt
as an exponent. (This mainly an ergonomic issue, as auint
should be large enough to store any reasonable exponent.)I think it would be better to have a signature like
(Note that
pow
currently uses some bitwise operations for efficiency, the proposed type constraints do not reflect that.)Alternatively, to keep it simple the exponent could just be a constant-size unsigned integer (
u32
should be sufficient [1]).[1] pow(1.1, pow(2, 32)) ~= pow(10, 177780229)
The text was updated successfully, but these errors were encountered: