Math.Log Method (Double)
.NET Framework 4.5
Returns the natural (base e) logarithm of a specified number.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Parameters
- d
- Type: System.Double
The number whose logarithm is to be found.
Return Value
Type: System.DoubleOne of the values in the following table.
d parameter | Return value |
|---|---|
Positive | The natural logarithm of d; that is, ln d, or log e d |
Zero | |
Negative | |
Equal to NaN | |
Equal to PositiveInfinity |
The following example illustrates the Log method.
using System; public class Example { public static void Main() { Console.WriteLine(" Evaluate this identity with selected values for X:"); Console.WriteLine(" ln(x) = 1 / log[X](B)"); Console.WriteLine(); double[] XArgs = { 1.2, 4.9, 9.9, 0.1 }; foreach (double argX in XArgs) { // Find natural log of argX. Console.WriteLine(" Math.Log({0}) = {1:E16}", argX, Math.Log(argX)); // Evaluate 1 / log[X](e). Console.WriteLine(" 1.0 / Math.Log(e, {0}) = {1:E16}", argX, 1.0 / Math.Log(Math.E, argX)); Console.WriteLine(); } } } // This example displays the following output: // Evaluate this identity with selected values for X: // ln(x) = 1 / log[X](B) // // Math.Log(1.2) = 1.8232155679395459E-001 // 1.0 / Math.Log(e, 1.2) = 1.8232155679395459E-001 // // Math.Log(4.9) = 1.5892352051165810E+000 // 1.0 / Math.Log(e, 4.9) = 1.5892352051165810E+000 // // Math.Log(9.9) = 2.2925347571405443E+000 // 1.0 / Math.Log(e, 9.9) = 2.2925347571405443E+000 // // Math.Log(0.1) = -2.3025850929940455E+000 // 1.0 / Math.Log(e, 0.1) = -2.3025850929940455E+000
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.