The log10l()
function takes an argument of type double
as input and returns the base-10 logarithm of . log10l()
in C is defined in the <math.h>
header file. The returned value is equivalent to the following in mathematical notation:
The function is defined in the C++ <math.h>
header file as:
long double log10l(double x);
Below is an example of how to use the log10l()
function, as well as a comparison of log10l()
and log10()
:
#include <stdio.h>#include <math.h>int main() {long double result = log10l(3.0);double result1 = log10(3.0);printf("Result of log10l(3.0): %f\n", result);printf("Result of log10(3.0): %f\n", result1);return 0;}
The difference between functions log10
and log10l
is that log10
simply has a return type of double
compared to the return type of log10l
, which is long double
.
Below are the ways in which the results of the log10l
function vary in different ranges of parameter x
:
If x
is less than 0, the results are not a number (NAN
)
If x
is greater than 0, the results are legitimate
If x
is equal to 0, the result is -
#include <stdio.h>#include <math.h>#include <iostream>using namespace std;int main() {//long double result = log10l(0.0);long double result1 = log10(0.0);long double result2 = log10(-3.0);long double result3 = log10(3.0);cout<<"for x < 0: "<< result2<<endl;cout<<"for x > 0: "<< result3<<endl;cout<<"for x = 0: "<< result1<<endl;return 0;}
Free Resources