r*********e 发帖数: 29495 | | c****e 发帖数: 7 | 2 Here is my answer to your question. It's NOT optimized for high precision,
but it shows the basic concept.
y=2^x -> lny=x*ln2 --> y=e^(x*ln2)
By using Taylor series expansion, e^x=sum(x^2/n!),n=0,1,2,3,...,
ln(1+x)=sum[(-1)^(n+1)*x^2/n!], -1
You need two steps to obtain 2^x:
1) calculate ln(1+1); Simply, you may just use ln2 as an input ln2=0.
69314718055994530941723212145818.
2) Calculate e^(x*ln2)
The c code was tested on DEV C++ 5.0. Please take care the precision you
need
【在 r*********e 的大作中提到】 : 多谢
| r*****e 发帖数: 7853 | 3 take the bit from x
【在 r*********e 的大作中提到】 : 多谢
|
|