0 out of 1 rated this helpful - Rate this topic

# Math.Log Method (Double)

.NET Framework 4

Returns the natural (base e) logarithm of a specified number.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
```public static double Log(
double d
)
```

#### Parameters

d
Type: System.Double
A number whose logarithm is to be found.

#### Return Value

Type: System.Double
One 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

NaN

Equal to PositiveInfinity

PositiveInfinity

Parameter d is specified as a base 10 number.

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

```

#### .NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

#### .NET Framework Client Profile

Supported in: 4, 3.5 SP1

#### Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.