C# has a built-in Math
class that provides useful mathematical functions and operations. The class has the Log()
function, which is used to compute the log of a specific number.
public static double Log (double value);
value
: It is of the Double
type and represents the input value that is determined by finding Log()
. Its range is all double numbers.Double
: It returns a Double
number representing the natural log of the value
.
NaN
: It returns this for negative or NaN
input in value
.
PositiveInfinity
: It returns this if value
is PositiveInfinity
.
NegativeInfinity
: It returns this if value
is 0
.
The natural log is the log to the base
e
, which is a mathematical expression with value 2.71828.
public static double Log (double value, double newbase);
value
: It is one of the Double
type and represents the input value, which is determined by finding Log()
. Its range is all double numbers.newbase
: It is of the Double
type and represents the new base value for Log()
. Its range is all double numbers.Double
: It returns a Double
number representing the log to the base newbase
of the value
.
NaN
: It returns this if:
value
< 0; newbase
= anyvalue
= any; newbase
< 0value
!= 1; newbase
= 0value
!= 1; newbase
= +∞value
= NaN; newbase
= anyvalue
= any; newbase
= NaNvalue
= any; newbase
= 1PositiveInfinity
: It returns this if:
value
= 0; 0 < newbase
< 1value
= + ∞; newbase
> 1NegativeInfinity
: It returns this if:
value
= 0; newbase
> 1value
= +∞; 0 < newbase
< 1using System;class Educative{static void Main(){Double result = Math.Log(1.2);System.Console.WriteLine("Log(1.2) = "+ result);Double result1 = Math.Log(9.9, 0.1);System.Console.WriteLine("Log(9.9, 0.1) = "+ result1);}}