I need to evaluate a logarithm of any base, it does not matter, to some precision. Is there an algorithm for this? I program in Java, so I’m fine with Java code.
How to find a binary logarithm very fast? (O(1) at best) might be able to answer my question, but I don’t understand it. Can it be clarified?
Use this identity:
Where
logcan be a logarithm function in any base,nis the number andbis the base. For example, in Java this will find the base-2 logarithm of 256:Math.log()uses basee, by the way. And there’s alsoMath.log10(), which uses base10.