Format
#include <math.h> double log10(double x);
Language Level: ANSI, POSIX, XPG4
log10 calculates the base 10 logarithm of x.
Return Value
log10 returns the computed value. If x is
negative, log10 sets errno to EDOM and may return the value
-HUGE_VAL. If x is zero, log10 returns the value
-HUGE_VAL, and may set errno to ERANGE.
Example
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);
return 0;
/******************************************************
The output should be:
The base 10 logarithm of 1000.000000 is 3.000000 ******************************************************/ }
![]()
exp -- Calculate Exponential Function
log -- Calculate Natural Logarithm
pow -- Compute Power
<math.h>