Math.Log10() Method in C#


The Math.Log10() method in C# is returned to the base 10 logarithms of a specified number.

Syntax

public static double Log10 (double val);

Here, Val is the number whose logarithm we want.

The Log10() method returns −

Val parameterReturns
PositiveThe base 10 log of d; that is, log 10d.
ZeroNegativeInfinity
NegativeNaN
Equal to NaNNaN
Equal to PositiveInfinityPositiveInfinity

Let us now see an example to implement Math.Log10() method −

Example

using System;
public class Demo {
   public static void Main(){
      double val1 = Double.PositiveInfinity; ;
      double val2 = Double.NegativeInfinity;
      Console.WriteLine(Math.Log10(val1));
      Console.WriteLine(Math.Log10(val2));
   }
}

Output

This will produce the following output −

∞
NaN

Let us see another example to implement Math.Log10() method −

Example

using System;
public class Demo {
   public static void Main(){
      double val1 = 0;
      double val2 = 1;
      double val3 = Double.NaN;
      Console.WriteLine(Math.Log10(val1));
      Console.WriteLine(Math.Log10(val2));
      Console.WriteLine(Math.Log10(val3));
   }
}

Output

This will produce the following output −

-∞
0
NaN

Updated on: 04-Nov-2019

241 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements