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

老外的帖子

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

Sincey = 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 isAbramowitz and Stegun.

猜你喜欢

转载自vergilwang.iteye.com/blog/2011259
今日推荐