Stop making horrible iterative procedures to acheive this; it's silly. The whole point of a logarithmic function is to acheive what you're trying to do.

Given the number X, LN(X) / LN(B) is an integer if X is a power of B

I did a little research, and some testing. My iterative solution is faster than the logarithmic one, but it only works for integers... However, if I changed it to handle floating point numbers, it would be slower, if X is very small and B is very large. The logarithmic function seems to calculate at a constant speed no matter what. I looked up natural lograthims on the internet, the equation to solve them seems to be iterative... does this mean that the natural log function is built into most FPU's?