C# Math.Log10() – Examples
In this tutorial, we will learn about the C# Math.Log10() method, and learn how to use this method to compute base 10 logarithm of a specified number, with the help of examples.
Log10(Double d)
Math.Log10(d) returns the base 10 logarithm of a specified number d
.
ADVERTISEMENT
Syntax
The syntax of Log10() method is
Math.Log10(Double d)
where
Parameter | Description |
---|---|
d | The double value, whose base 10 logarithm is to be found. |
Return Value
The method returns value of type double.
Example 1 – Log10(d)
In this example, we will find the base 10 logarithm of the following numbers.
- Positive Value
- Negative Value
- Positive Infinity
- Negative Infinity
- Zero
C# Program
using System; class Example { static void Main(string[] args) { Double d, result; d = 8; result = Math.Log10(d); Console.WriteLine($"Log({d}) = {result}"); d = -7; result = Math.Log10(d); Console.WriteLine($"Log({d}) = {result}"); d = Double.PositiveInfinity; result = Math.Log10(d); Console.WriteLine($"Log({d}) = {result}"); d = Double.NegativeInfinity; result = Math.Log10(d); Console.WriteLine($"Log({d}) = {result}"); d = 0; result = Math.Log10(d); Console.WriteLine($"Log({d}) = {result}"); } }
Output
Log(8) = 0.903089986991944 Log(-7) = NaN Log(∞) = ∞ Log(-∞) = NaN Log(0) = -∞
Conclusion
In this C# Tutorial, we have learnt the syntax of C# Math.Log10() method, and also learnt how to use this method, with the help of C# example programs.