C# Tutorial C# Advanced C# Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

C# - Math Log10() Method



The C# Math Log10() method returns the base-10 logarithm of a given number. In special cases it returns the following:

  • If the argument is NaN or less than zero, the method returns NaN.
  • If the argument is PositiveInfinity, the method returns PositiveInfinity.
  • If the argument is zero, the method returns NegativeInfinity.

Syntax

public static double Log10 (double arg);

Parameters

arg Specify the number whose logarithm is to be found.

Return Value

Returns the base-10 logarithm of a given number.

Example:

In the example below, Log10() method is used to calculate the base-10 logarithm of a given number.

using System;

class MyProgram {
  static void Main(string[] args) {
    Console.WriteLine(Math.Log10(10)); 
    Console.WriteLine(Math.Log10(50)); 
    Console.WriteLine(Math.Log10(100));  
  }
}

The output of the above code will be:

1
1.69897000433602
2

❮ C# Math Methods

5