語言

BigInteger.Log 方法

定義

回傳指定數字的對數。

多載

名稱 Description
Log(BigInteger)

回傳指定數字的自然(基底 e)對數。

Log(BigInteger, Double)

回傳指定底數中指定數字的對數。

Log(BigInteger)

來源:
BigInteger.cs
來源:
BigInteger.cs
來源:
BigInteger.cs
來源:
BigInteger.cs
來源:
BigInteger.cs

回傳指定數字的自然(基底 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)

來源:
BigInteger.cs
來源:
BigInteger.cs
來源:
BigInteger.cs
來源:
BigInteger.cs
來源:
BigInteger.cs

回傳指定底數中指定數字的對數。

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參數以十為底數指定。

方法的精確返回值取決於 的 value 符號,以及 的 baseValue符號與值,如下表所示。

value 參數 baseValue 參數 返回值
value > 0 (0 <baseValue< 1) -或-(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 於原始數值型的方法。

另請參閱

適用於