Namespaces
Variants

log10, log10f, log10l

From cppreference.net
< c ‎ | numeric ‎ | math
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99) (C99) (C99) (C23)
Maximum/minimum operations
Exponential functions
log10
(C99)
(C99) (C23)
(C23)
(C23)
Power functions
Trigonometric and hyperbolic functions
Nearest integer floating-point
(C99) (C99) (C99)
(C23) (C23) (C23) (C23)
Floating-point manipulation
Narrowing operations
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
Quantum and quantum exponent
Decimal re-encoding functions
Total order and payload functions
Classification
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Types
Macro constants
Special floating-point values
Arguments and return values
Error handling
Fast operation indicators
Definiert im Header <math.h>
float log10f ( float arg ) ;
(1) (seit C99)
double log10 ( double arg ) ;
(2)
long double log10l ( long double arg ) ;
(3) (seit C99)
Definiert im Header <tgmath.h>
#define log10( arg )
(4) (seit C99)
1-3) Berechnet den dekadischen Logarithmus (Basis- 10 ) von arg .
4) Typgenerisches Makro: Wenn arg den Typ long double hat, wird log10l aufgerufen. Andernfalls, wenn arg einen Ganzzahltyp oder den Typ double hat, wird log10 aufgerufen. Andernfalls wird log10f aufgerufen.

Inhaltsverzeichnis

Parameter

arg - Gleitkommawert

Rückgabewert

Wenn keine Fehler auftreten, wird der dekadische Logarithmus (Basis- 10 ) von arg ( log 10 (arg) oder lg(arg) ) zurückgegeben.

Wenn ein Domänenfehler auftritt, wird ein implementierungsdefinierter Wert zurückgegeben (NaN, sofern unterstützt).

Wenn ein Polfehler auftritt, -HUGE_VAL , -HUGE_VALF , oder -HUGE_VALL wird zurückgegeben.

Fehlerbehandlung

Fehler werden gemeldet, wie in math_errhandling festgelegt.

Ein Domänenfehler tritt auf, wenn arg kleiner als null ist.

Polfehler kann auftreten, wenn arg null ist.

Wenn die Implementierung IEEE-Gleitkommaarithmetik (IEC 60559) unterstützt,

  • Wenn das Argument ±0 ist, wird -∞ zurückgegeben und FE_DIVBYZERO wird ausgelöst.
  • Wenn das Argument 1 ist, wird +0 zurückgegeben
  • Wenn das Argument negativ ist, wird NaN zurückgegeben und FE_INVALID wird ausgelöst.
  • Wenn das Argument +∞ ist, wird +∞ zurückgegeben
  • Wenn das Argument NaN ist, wird NaN zurückgegeben.

Beispiel

#include <errno.h>
#include <fenv.h>
#include <float.h>
#include <math.h>
#include <stdio.h>
// #pragma STDC FENV_ACCESS ON
int main(void)
{
    printf("log10(1000) = %f\n", log10(1000));
    printf("log10(0.001) = %f\n", log10(0.001));
    printf("base-5 logarithm of 125 = %f\n", log10(125) / log10(5));
    // special values
    printf("log10(1) = %f\n", log10(1));
    printf("log10(+Inf) = %f\n", log10(INFINITY));
    // error handling
    errno = 0; feclearexcept(FE_ALL_EXCEPT);
    printf("log10(0) = %f\n", log10(0));
    if (errno == ERANGE)
        perror("    errno == ERANGE");
    if (fetestexcept(FE_DIVBYZERO))
        puts("    FE_DIVBYZERO raised");
}

Mögliche Ausgabe:

log10(1000) = 3.000000
log10(0.001) = -3.000000
base-5 logarithm of 125 = 3.000000
log10(1) = 0.000000
log10(+Inf) = inf
log10(0) = -inf
    errno == ERANGE: Numerical result out of range
    FE_DIVBYZERO raised

Referenzen

  • C23-Standard (ISO/IEC 9899:2024):
  • 7.12.6.8 Die log10-Funktionen (S: TBD)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S: TBD)
  • F.10.3.8 Die log10-Funktionen (S: TBD)
  • C17-Standard (ISO/IEC 9899:2018):
  • 7.12.6.8 Die log10-Funktionen (S: 179)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S: 272-273)
  • F.10.3.8 Die log10-Funktionen (S: 380)
  • C11-Standard (ISO/IEC 9899:2011):
  • 7.12.6.8 Die log10-Funktionen (S: 245)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S: 373-375)
  • F.10.3.8 Die log10-Funktionen (S: 522)
  • C99-Standard (ISO/IEC 9899:1999):
  • 7.12.6.8 Die log10-Funktionen (S. 225-226)
  • 7.22 Typgenerische Mathematik <tgmath.h> (S. 335-337)
  • F.9.3.8 Die log10-Funktionen (S. 459)
  • C89/C90 Standard (ISO/IEC 9899:1990):
  • 4.5.4.5 Die log10-Funktion

Siehe auch

(C99) (C99)
berechnet den natürlichen Logarithmus (Basis- e ) ( ln(x) )
(Funktion)
(C99) (C99) (C99)
berechnet den Logarithmus zur Basis 2 ( log 2 (x) )
(Funktion)
(C99) (C99) (C99)
berechnet den natürlichen Logarithmus (Basis- e ) von 1 plus der gegebenen Zahl ( ln(1+x) )
(Funktion)