I would like to find the upward rounded value of logarithm of integer n to integer base b. In code:
result = int(ceil(log(n, b)))
The problem is that sometimes the value cannot be represented exactly in floating point, overestimating the result. For example:
log(125, 5) == int(ceil(3.0000000000000004)) == 4
What can I do about this? Subtracting tiny epsilon would underestimate it elsewhere. Is there a way to side step floating point calculation entirely, kind of like when using base 2?
I could use a loop to find the logarithm but I was wondering whether it is possible to do this in constant time.