Skip to content
Related Articles
Open in App
Not now

Related Articles

C# | Math.Log10() Method

Improve Article
Save Article
  • Last Updated : 31 Jan, 2019
Improve Article
Save Article

In C#, Math.Log10() is a Math class method. It is used to return the base 10 logarithm of a specified number.


public static double Log10(double val)


val: It is the specified number whose logarithm to be calculated and its type is System.Double.

Return Value: It returns the logarithm of val(base 10 log of val) and its type is System.Double.

Note: Parameter val is always specified as a base 10 number. The return value is depend on the argument passed. Below are some cases:

  • If the argument is positive then method will return the natural logarithm or log10(val).
  • If the argument is zero, then the result is NegativeInfinity.
  • If the argument is Negative(less than zero) or equal to NaN, then the result is NaN.
  • If the argument is PositiveInfinity, then the result is PositiveInfinity.
  • If the argument is NegativeInfinity, then the result is NaN.


// C# program to demonstrate working
// of Math.Log10(Double) method
using System;
class Geeks {
    // Main Method
    public static void Main(String[] args)
        // double values whose logarithm 
        // to be calculated
        double a = 4.55;
        double b = 0;
        double c = -2.45;
        double nan = Double.NaN;
        double positiveInfinity = Double.PositiveInfinity;     
        double negativeInfinity = Double.NegativeInfinity;
        // Input is positive number so output
        // will be logarithm of number
        // positive zero as argument, so output 
        // will be -Infinity
        // Input is negative number so output
        // will be NaN
        // Input is NaN so output
        // will be NaN
        // Input is PositiveInfinity so output
        // will be Infinity
        // Input is NegativeInfinity so output
        // will be NaN




My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!