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 parameter Returns
Positive The base 10 log of d; that is, log 10d.
Zero NegativeInfinity
Negative NaN
Equal to NaN NaN
Equal to PositiveInfinity PositiveInfinity

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: 2019-11-04T10:55:43+05:30

381 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements