English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++The log10The () function returns the common logarithm of the parameter (base10logarithm to the base).
This function calculates<cmath>defined in the header file.
log10x = log10(x)
double log10 (double x); float log10 (float x); long double log10 (long double x); double log10 (T x); //is of integer type
log10The () function uses a range of[0, ∞]is a single required parameter.
If the value is less than 0, then log10The () returns NaN (not a number).
log10The () function returns the logarithm of a number to the base10logarithm to the base.
parameter (x) | returns VALUE |
---|---|
x > 1 | Positive |
x = 1 | 0 |
0 > x > 1 | Negative |
x = 0 | -∞ (-infinity) |
x < 0 | nan (not a number) |
#include <iostream> #include <cmath> 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; }
When running the program, the output is:
log10(x) = 1.11581 log10(x) = nan
#include <iostream> #include <cmath> using namespace std; int main () { int x = 2; double result; result = log10(x); cout << "log10(x) = " << result << endl; return 0; }
When running the program, the output is:
log10(x) = 0.30103