log, logl
Nach oben zu math.h - Index
Header-Datei
math.h
Kategorie
Mathematische Routinen
Prototyp
double log(double x);
long double logl(long double x);
Beschreibung
Berechnet den natürlichen Logarithmus von x.
log berechnet den natürlichen Logarithmus von x.
logl ist die long double-Version. Sie benötigt ein Argument vom Typ long double und gibt ein Ergebnis vom Typ long double zurück.
Rückgabewert
Bei erfolgreicher Ausführung geben log und logl den berechneten Wert, ln(x), zurück.
errno
EDOM |
Domain error (Domain-Fehler) |
Wenn x gleich 0 ist, geben die Funktionen minus HUGE_VAL (log) bzw. minus _LHUGE_VAL (logl) zurück und weisen errno den Wert ERANGE zu. Die Fehlerbehandlung für diese Routinen kann über die Funktionen _matherr und _matherrl geändert werden.
Beispiel
#include <math.h>
#include <stdio.h>
int main(void)
{
double result;
double x = 8.6872;
result = log(x);
printf("The natural log of %lf is %lf\n", x, result);
return 0;
}
Portabilität
POSIX | Win32 | ANSI C | ANSI C++ | |
---|---|---|---|---|
log |
+ |
+ |
+ |
+ |
logl |
+ |
+ |
+ |