Rate This Document
Findability
Accuracy
Completeness
Readability

log10

Compute the base-10 logarithm of a real number.

Interface Definition

C interface:

float log10f(float x);

double log10(double x);

Fortran interface:

RES = LOG10F(X);

RES = LOG10(X);

Parameters

Parameter

Type

Description

Input/Output

x

  • For log10f, x is of the single-precision floating-point type.
  • For log10, x is of the double-precision floating-point type.

Floating-point value of the input data

Input

Return Value

  1. The base-10 logarithm y of x is returned. y ∈ (-INF, +INF)
  2. If the input x is ±0, the return value is -∞.
  3. If the input x is 1, the return value is 0.
  4. If the input x is a negative number, the return value is NaN.
  5. If the input x is +∞, the return value is +∞.
  6. If the input x is NaN, the return value is NaN.

Dependencies

C: "km.h"

Fortran: "km.f03"

Examples

C interface:

    double pi = acos(-1); 
    // typical usage 
    double x1 = 10.0, x2 = 2.0, x3 = 125, x4 = 5; 
    // special handing 
    double a = 0.0, b = INFINITY, c = -INFINITY, d = NAN, e = 1.0; 
    // print result 
    printf("base-5 logarithm of 125 = %.15f\n", log10(x3)/log10(x4)); 
    printf("log10(1.0) = %.15f\n", log10(e)); 
    printf("log10(10.0) = %.15f\n", log10(x1)); 
    printf("log10(2.0) = %.15f\n", log10(x2)); 
    printf("log10(0.0) = %.15f\n", log10(a)); 
    printf("log10(INFINITY) = %.15f\n", log10(b)); 
    printf("log10(-INFINITY) = %.15f\n", log10(c)); 
    printf("log10(NAN) = %.15f\n", log10(d)); 
    /* 
     *  base-5 logarithm of 125 = 3.000000000000000 
     *  log10(1.0) = 0.000000000000000 
     *  log10(10.0) = 1.000000000000000 
     *  log10(2.0) = 0.301029995663981 
     *  log10(0.0) = -inf 
     *  log10(INFINITY) = inf 
     *  log10(-INFINITY) = nan 
     *  log10(NAN) = nan 
     * 
     * */

Fortran interface:

    REAL(8) :: X = 2 
    PRINT*,  LOG10(X) 
    ! 
    ! OUTPUT 
    !     0.301029995663981 
    !