How Math.Pow (and so on) actually works

后端 未结 1 602
感情败类
感情败类 2020-11-28 15:18

So I was googling for a long time and i found almost nothing. I found some info about possible implementation of Math.Pow from this url, but they are inaccurate, for example

相关标签:
1条回答
  • 2020-11-28 15:56

    pow is usually evaluated by this formula:

    x^y = exp2(y*log2(x))
    

    Functions exp2(x),log2(x) are directly implemented in FPU. If you want to implement bignums then they can also be evaluated by basic operators with use of precomputed table of sqrt-powers like:

    2^1/2, 2^1/4, 2^1/8, 2^1/16, 2^1/32 ...
    

    to speed up the process

    0 讨论(0)
提交回复
热议问题