initial upload
This commit is contained in:
18
src/bigmath/chain/util.cpp
Normal file
18
src/bigmath/chain/util.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user