From a793df3e2a07c65f36fb2f5f43d2c51ab0c47bf2 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Wed, 10 Apr 2024 16:54:50 +0300 Subject: Added help message & fixed blocksize bug The bug was caused by integer overflow with too large precisions. --- intmath.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'intmath.c') diff --git a/intmath.c b/intmath.c index 9e1f3ed..a4738b9 100644 --- a/intmath.c +++ b/intmath.c @@ -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) { -- cgit v1.2.3