BigInteger.Log 方法

定义

返回指定数字的对数。

重载

名称 说明
Log(BigInteger)

返回指定数字的自然 (base e) 对数。

Log(BigInteger, Double)

返回指定基数中指定数字的对数。

Log(BigInteger)

返回指定数字的自然 (base e) 对数。

public:
 static double Log(System::Numerics::BigInteger value);
public static double Log(System.Numerics.BigInteger value);
static member Log : System.Numerics.BigInteger -> double
Public Shared Function Log (value As BigInteger) As Double

参数

value
BigInteger

要找到其对数的数字。

返回

自然(基 e)对 value数,如“备注”部分中的表格所示。

例外

自然日志的数据类型 value 范围 Double 不足。

注解

参数 value 指定为基数 10。

此方法的精确返回值取决于 value符号,如下表所示。

参数符号value 返回值
积极 的自然对数 value,即 ln value或 log evalue
NegativeInfinity
消极 NaN

若要计算值的 BigInteger 基数 10 对数,请调用 Log10 该方法。 若要计算另一个基数中的数字的对数,请调用该方法 Log(BigInteger, Double)

可以通过调用 Log 方法以及 Math.Exp 该方法来查找数字的平方根。 请注意,结果是 Double.PositiveInfinity 结果大于 Double.MaxValue。 以下示例计算值数组中每个元素的 BigInteger 平方根。

using System;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      BigInteger[] values = { 2, 100, BigInteger.Pow(1000, 100), 
                              BigInteger.Pow(2, 64) };
      foreach (var value in values)                                    
         Console.WriteLine("The square root of {0} is {1}", value, 
                           Math.Exp(BigInteger.Log(value) / 2));
   }
}
// The example displays the following output:
//    The square root of 2 is 1.41421356237309
//    The square root of 100 is 10
//    The square root of 1000000000000000000000000000000000000000000000000000000000000
//    00000000000000000000000000000000000000000000000000000000000000000000000000000000
//    00000000000000000000000000000000000000000000000000000000000000000000000000000000
//    00000000000000000000000000000000000000000000000000000000000000000000000000000000
//     is 9.99999999999988E+149
//    The square root of 18446744073709551616 is 4294967296
open System
open System.Numerics

let values = [| 2I; 100I; BigInteger.Pow(1000I, 100); BigInteger.Pow(2I, 64) |]

for value in values do
    printfn $"The square root of {value} is {Math.Exp(BigInteger.Log(value) / 2.)}"
// The example displays the following output:
//    The square root of 2 is 1.41421356237309
//    The square root of 100 is 10
//    The square root of 1000000000000000000000000000000000000000000000000000000000000
//    00000000000000000000000000000000000000000000000000000000000000000000000000000000
//    00000000000000000000000000000000000000000000000000000000000000000000000000000000
//    00000000000000000000000000000000000000000000000000000000000000000000000000000000
//     is 9.99999999999988E+149
//    The square root of 18446744073709551616 is 4294967296
Imports System.Numerics

Module Example
   Public Sub Main()
      Dim values() As BigInteger = { 2, 100, BigInteger.Pow(1000, 100), 
                                     BigInteger.Pow(2, 64) }
      For Each value In values                                    
         Console.WriteLine("The square root of {0} is {1}", value, 
                           Math.Exp(BigInteger.Log(value) / 2))
      Next                                     
   End Sub
End Module
' The example displays the following output:
'    The square root of 2 is 1.41421356237309
'    The square root of 100 is 10
'    The square root of 1000000000000000000000000000000000000000000000000000000000000
'    00000000000000000000000000000000000000000000000000000000000000000000000000000000
'    00000000000000000000000000000000000000000000000000000000000000000000000000000000
'    00000000000000000000000000000000000000000000000000000000000000000000000000000000
'     is 9.99999999999988E+149
'    The square root of 18446744073709551616 is 4294967296

此方法对应于 Math.Log(Double) 基元数值类型的方法。

另请参阅

适用于

Log(BigInteger, Double)

返回指定基数中指定数字的对数。

public:
 static double Log(System::Numerics::BigInteger value, double baseValue);
public static double Log(System.Numerics.BigInteger value, double baseValue);
static member Log : System.Numerics.BigInteger * double -> double
Public Shared Function Log (value As BigInteger, baseValue As Double) As Double

参数

value
BigInteger

要找到其对数的数字。

baseValue
Double

对数的基数。

返回

“备注”部分中的表所示的基 baseValue 对数 value

例外

日志的数据类型 value 范围 Double 不足。

注解

参数valuebaseValue指定为 10 个基数。

方法的精确返回值取决于符号 value 和符号和值 baseValue,如下表所示。

value 参数 baseValue 参数 返回值
value > 0 (0 <baseValue< 1) -or-(baseValue> 1) logbaseValue(value
value < 0 (任何值) Double.NaN
(任何值) baseValue < 0 Double.NaN
value != 1 baseValue = 0 Double.NaN
value != 1 baseValue = Double.PositiveInfinity Double.NaN
(任何值) baseValue = Double.NaN Double.NaN
(任何值) baseValue = 1 Double.NaN
value = 0 0 <baseValue< 1 Double.PositiveInfinity
value = 0 baseValue > 1 Double.PositiveInfinity
value = 1 baseValue = 0 0
value = 1 baseValue = Double.PositiveInfinity 0

若要计算值的 BigInteger 基数 10 对数,请调用 Log10 该方法。 若要计算数字的自然对数,请调用该方法 Log(BigInteger)

此方法对应于 Math.Log 基元数值类型的方法。

另请参阅

适用于