MathF.Log10() Method in C# with Examples


The MathF.Log10() method in C# is used to return the base 10 logarithm of a specified number.

Syntax

Following is the syntax −

public static float Log10 (float val);

Above, Val is the number whose logarithm is to be calculated.

Example

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

using System;
public class Demo {
   public static void Main(){
      float val1 = 45.9f;
      float val2 = -4.35f;
      Console.WriteLine(MathF.Log10(val1));
      Console.WriteLine(MathF.Log10(val2));
   }
}

Output

This will produce the following output −

1.661813
NaN

Example

Let us now see another example to implement the MathF.Log10() method −

using System;
public class Demo {
   public static void Main(){
      float val1 = 1.0f;
      float val2 = 10.0f;
      Console.WriteLine(MathF.Log10(val1));
      Console.WriteLine(MathF.Log10(val2));
   }
}

Output

This will produce the following output −

0
1

Updated on: 14-Nov-2019

26 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements