log10() — Calculate Base 10 Logarithm

Format

#include <math.h>
double log10(double x);

Language Level: ANSI

Threadsafe: Yes.

Description

The log10() function calculates the base 10 logarithm of x.

Return Value

The log10() function returns the computed value. If x is negative, log10()sets errno to EDOM and might return the value -HUGE_VAL. If x is zero, the log10() function returns the value -HUGE_VAL, and might set errno to ERANGE.

Example that uses log10()

This example calculates the base 10 logarithm of 1000.0.

#include <math.h>
#include <stdio.h>
 
int main(void)
{
   double x = 1000.0, y;
 
   y = log10(x);
 
   printf("The base 10 logarithm of %lf is %lf\n", x, y);
}
 
/********************  Output should be similar to:  **************
 
The base 10 logarithm of 1000.000000 is 3.000000
*/

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]