📅  最后修改于: 2020-09-25 07:49:31             🧑  作者: Mango
此函数在
[Mathematics] log10x = log10(x) [In C++ Programming]
double log10 (double x);
float log10 (float x);
long double log10 (long double x);
double log10 (T x); // For integral type
log10() 函数采用范围为[0,∞]的单个必需参数。
如果该值小于0,则log10()返回NaN
(非数字)。
log10() 函数返回数字的以10为底的对数。
Parameter (x) | Return VALUE |
---|---|
x > 1 | Positive |
x = 1 | 0 |
0 > x > 1 | Negative |
x = 0 | -∞ (- infinity) |
x < 0 | nan (Not a Number) |
#include
#include
using namespace std;
int main ()
{
double x = 13.056, result;
result = log10(x);
cout << "log10(x) = " << result << endl;
x = -3.591;
result = log10(x);
cout << "log10(x) = " << result << endl;
return 0;
}
运行该程序时,输出为:
log10(x) = 1.11581
log10(x) = nan
#include
#include
using namespace std;
int main ()
{
int x = 2;
double result;
result = log10(x);
cout << "log10(x) = " << result << endl;
return 0;
}
运行该程序时,输出为:
log10(x) = 0.30103