This code is usually running on an embedded CPU without FPU. In addtition to its inefficience, the algorithm is also much harder to understand. Replace the logarithm formula with a simple loop. (cherry picked from commit f2e0f7e3)