exp(n)值为e^n次方;
log函数包括两种函数: 一种以e为底的log()函数;另一种为以10为底的log10函数。
e就是自然对数,大约等于2.71828.
#include<iostream>
#include<cmath>using namespace std;void main()
{double a=10,b=20;cout<<log(a)<<endl;cout<<log(exp(a))<<endl;cout<<log10(b)<<endl;
}
另外如果自定义以m为底,求log n的值需要double a=log(n)/log(m);
#include<iostream>
#include<cmath>using namespace std;int main()
{double a = 2, b = 5; //以5为底的对数函数 for(b = 2; b <= 16;b = b + 2){cout<<"b= "<<b<<"时,以2为底的对数函数="<<log(b)/log(a)<<endl;}return 0;
}