Files
libbigmath/src/bigmath/chain/util.cpp
2026-02-26 12:12:11 -06:00

18 lines
331 B
C++

#include "util.hpp"
namespace bigmath {
u64 ipow(u64 b, u64 p) {
// FROM stack overflow
// "The most efficient way to implement [int pow]"
u64 r = 1;
for(;;) {
if(p & 1) r *= b;
p >>= 1;
if(!p) break;
b *= b;
}
return r;
}
}