C ++ log10 () - C ++ Standardbibliothek

Die Funktion log10 () in C ++ gibt den allgemeinen Logarithmus (Logarithmus zur Basis 10) des Arguments zurück.

Diese Funktion ist in der Header-Datei definiert.

(Mathematik) log 10 x = log10 (x) (In C ++ - Programmierung)

log10 () Prototyp (Stand C ++ 11 Standard)

double log10 (double x); float log10 (float x); langes doppeltes log10 (langes doppeltes x); doppeltes log10 (T x); // Für integralen Typ

log10 () Parameter

Die Funktion log10 () verwendet ein einzelnes obligatorisches Argument im Bereich (0, ∞) .

Wenn der Wert kleiner als 0 ist, gibt log10 () NaN(keine Zahl) zurück.

log10 () Rückgabewert

Die Funktion log10 () gibt den Logarithmus zur Basis 10 einer Zahl zurück.

Parameter (x) Rückgabewert
x> 1 Positiv
x = 1 0
0> x> 1 Negativ
x = 0 -∞ (- unendlich)
x <0 nan (Keine Nummer)

Beispiel 1: Wie funktioniert log10 ()?

 #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; )

Wenn Sie das Programm ausführen, lautet die Ausgabe wie folgt:

 log10 (x) = 1,11581 log10 (x) = nan

Beispiel 2: log10 () mit integriertem Typ

 #include #include using namespace std; int main () ( int x = 2; double result; result = log10(x); cout << "log10(x) = " << result << endl; return 0; )

Wenn Sie das Programm ausführen, lautet die Ausgabe wie folgt:

 log10 (x) = 0,30103

Interessante Beiträge...