We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
pow
self
1 parent 547b713 commit e5ca8cdCopy full SHA for e5ca8cd
1 file changed
library/core/src/num/uint_macros.rs
@@ -3317,6 +3317,15 @@ macro_rules! uint_impl {
3317
let mut acc = 1;
3318
3319
if intrinsics::is_val_statically_known(exp) {
3320
+ // change of base:
3321
+ // if base == 2 ** k, then
3322
+ // (2 ** k) ** n
3323
+ // == 2 ** (k * n)
3324
+ // == 1 << (k * n)
3325
+ if self.is_power_of_two() {
3326
+ return (1 as Self) << (2 * self.ilog2())
3327
+ }
3328
+
3329
while exp > 1 {
3330
if (exp & 1) == 1 {
3331
acc = acc * base;
0 commit comments