aboutsummaryrefslogtreecommitdiff
path: root/aberth/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'aberth/util.h')
-rw-r--r--aberth/util.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/aberth/util.h b/aberth/util.h
index a276e2a..49195b5 100644
--- a/aberth/util.h
+++ b/aberth/util.h
@@ -27,3 +27,14 @@ constexpr static T ceil2(T value) {
if (value2 == 0) return value << 1;
}
}
+
+template <typename T>
+constexpr static T ipow(T base, T ex) {
+ T x = 1, y = base;
+ while (ex > 0) {
+ if ((ex & 1) == 1) x *= y;
+ y *= y;
+ ex >>= 1;
+ }
+ return x;
+}