Fast implementation/approximation of pow() function in C/C++

老外的帖子

Sure - it's easy if you have exponential and natural log functions.

Since y = x^n, you can take the natural log of both sides:

ln(y) = n*ln(x)

Then taking the exponential of both sides gives you what you want:

y = exp(n*ln(x))

If you want something better, the best place I know to look is Abramowitz and Stegun.

你可能感兴趣的:(Fast implementation/approximation of pow() function in C/C++)