Log functions in C#



With C#, you can easily work with Logarithms. It has the following methods for Log as well as Log base 10.

Sr.No Method & Description
1 Log(Double)
Returns the natural (base e) logarithm of a specified number.
2 LogDouble)(Double,
Returns the logarithm of a specified number in a specified base.
3 Log10(Double)
Returns the base 10 logarithm of a specified number.

Let us see an example to work with Log functions in C# −

Example

using System;

class Demo {
   static void Main() {
      double val1 = Math.Log(1);
      Console.WriteLine(val1);

      double val2 = Math.Log10(1000);
      Console.WriteLine(val2);

   }
}
Updated on: 2020-06-21T12:31:31+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements