diff options
Diffstat (limited to 'intmath.c')
-rw-r--r-- | intmath.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -14,6 +14,18 @@ int int_pown(unsigned int base, unsigned int exp) { return res; } +int int_logn(unsigned int base, unsigned int a) { + unsigned int exp = 1; + int res = (int) base; + int lastres = res - 1; + while ((res < a) && (lastres < res)) { + lastres = res; + res *= base; + exp++; + } + return exp; +} + unsigned long long ull_pown(unsigned int base, unsigned int exp) { unsigned long long res = 1; while (exp > 0) { |