The log10() function in D uses the base 10 to calculate the logarithm of a number. The figure below shows the mathematical representation of the log10() function.
Note: We need to import
std.mathin our code, in order to use thelog10()function. We can import it like this:import std.math
Let’s look at the syntax for the log10() function.
// number should be float, double or real.
log10(number)
This function requires the 
log10() uses the base 10 to return the logarithm of a given number.
Note:
- If the parameter value is
 positive infinity, then thelog()returnspositive infinity.- If the parameter value is
 NaNornegative infinity, then thelog()function returnsNaN.- If the parameter value is
 -NaN, then thelog()function returns-NaN.- If the parameter value is <=
 0, then thelog()function returnsnegative infinity.
The code written below shows us how to use the log10() function in D:
import core.stdc.stdio;import std.stdio;//header required for functionimport std.math;int main(){//integerwriteln ("The value of log10(10) : ",log10(10));//positive double valuewriteln ("The value of log10(2.56) : ",log10(2.56));//ewriteln ("The value of log10(E) : ",log10(E));//exceptional outputswriteln ("The value of log10(-0.0) : ",log10(-0.0));writeln ("The value of log10(0.0) : ",log10(0.0));writeln ("The value of log10(real.infinity) : ",log10(real.infinity));writeln ("The value of log10(-real.infinity) : ",log10(-real.infinity));writeln ("The value of log10(real.nan) : ",log10(real.nan));writeln ("The value of log10(-real.nan) : ",log10(-real.nan));return 0;}
Line 4: We add the header std.math, which is required for the log10() function.
Line 9: We calculate the log base 10 of the integer value, using the log10() function.
Line 12: We calculate the log base 10 of the positive double value, using the log10() function.
Line 15: We calculate the log base 10 of e, using the log10() function.
Lines 18–25: We calculate the log base 10 of exceptional numbers, using the log10() function.