BigInteger BigInteger BigInteger BigInteger Struct

定義

表示任意大、帶正負號的整數。Represents an arbitrarily large signed integer.

public value class BigInteger : IComparable, IComparable<System::Numerics::BigInteger>, IEquatable<System::Numerics::BigInteger>, IFormattable
[System.Serializable]
public struct BigInteger : IComparable, IComparable<System.Numerics.BigInteger>, IEquatable<System.Numerics.BigInteger>, IFormattable
type BigInteger = struct
    interface IFormattable
Public Structure BigInteger
Implements IComparable, IComparable(Of BigInteger), IEquatable(Of BigInteger), IFormattable
繼承
BigIntegerBigIntegerBigIntegerBigInteger
屬性
實作

備註

BigInteger類型是不可變的類型表示任意大整數,其值在理論上沒有上限或下限。The BigInteger type is an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds. 成員BigInteger型別極為相似的其他整數類資料類型 ( ByteInt16Int32Int64SByteUInt16UInt32,和UInt64類型)。The members of the BigInteger type closely parallel those of other integral types (the Byte, Int16, Int32, Int64, SByte, UInt16, UInt32, and UInt64 types). 此型別不同於其他整數類資料類型中.NET Framework.NET Framework,其具有所指定的範圍及其MinValueMaxValue屬性。This type differs from the other integral types in the .NET Framework.NET Framework, which have a range indicated by their MinValue and MaxValue properties.

注意

因為BigInteger型別是不可變 (請參閱可變動性和 BigInteger 結構),因為它有沒有上限或下限的界限,OutOfMemoryException可能會導致任何作業中擲回BigInteger太成長值大型。Because the BigInteger type is immutable (see Mutability and the BigInteger Structure) and because it has no upper or lower bounds, an OutOfMemoryException can be thrown for any operation that causes a BigInteger value to grow too large.

BigInteger 物件具現化Instantiating a BigInteger Object

您可以具現化BigInteger物件以數種方式:You can instantiate a BigInteger object in several ways:

  • 您可以使用new關鍵字,並做為參數提供的任何整數或浮點值BigInteger建構函式。You can use the new keyword and provide any integral or floating-point value as a parameter to the BigInteger constructor. (浮點數的值會被截斷,才能指派給BigInteger。)下列範例說明如何使用new關鍵字來具現化BigInteger值。(Floating-point values are truncated before they are assigned to the BigInteger.) The following example illustrates how to use the new keyword to instantiate BigInteger values.

    BigInteger bigIntFromDouble = new BigInteger(179032.6541);
    Console.WriteLine(bigIntFromDouble);
    BigInteger bigIntFromInt64 = new BigInteger(934157136952);
    Console.WriteLine(bigIntFromInt64);
    // The example displays the following output:
    //   179032
    //   934157136952		
    
    Dim bigIntFromDouble As New BigInteger(179032.6541)
    Console.WriteLine(bigIntFromDouble)
    Dim bigIntFromInt64 As New BigInteger(934157136952)
    Console.WriteLine(bigIntFromInt64)
    ' The example displays the following output:
    '   179032
    '   934157136952		
    
  • 您可以宣告BigInteger變數並指派值,就像您一樣任何數值類型,只要該值是整數型別。You can declare a BigInteger variable and assign it a value just as you would any numeric type, as long as that value is an integral type. 下列範例會使用指派來建立BigInteger值從Int64The following example uses assignment to create a BigInteger value from an Int64.

    long longValue = 6315489358112;      
    BigInteger assignedFromLong = longValue;
    Console.WriteLine(assignedFromLong);
    // The example displays the following output:
    //   6315489358112
    
    Dim longValue As Long = 6315489358112      
    Dim assignedFromLong As BigInteger = longValue
    Console.WriteLine(assignedFromLong)
    ' The example displays the following output:
    '   6315489358112
    
  • 您可以指派十進位或浮點數的值給BigInteger物件,如果您將值轉換,或先將它轉換。You can assign a decimal or floating-point value to a BigInteger object if you cast the value or convert it first. 下列範例明確轉換 (在 C# 中),或將轉換 (在 Visual Basic)DoubleDecimalBigIntegerThe following example explicitly casts (in C#) or converts (in Visual Basic) a Double and a Decimal value to a BigInteger.

    BigInteger assignedFromDouble = (BigInteger) 179032.6541;
    Console.WriteLine(assignedFromDouble);   
    BigInteger assignedFromDecimal = (BigInteger) 64312.65m;      
    Console.WriteLine(assignedFromDecimal);
    // The example displays the following output:
    //   179032
    //   64312      
    
    Dim assignedFromDouble As BigInteger = CType(179032.6541, BigInteger)
    Console.WriteLine(assignedFromDouble)   
    Dim assignedFromDecimal As BigInteger = CType(64312.65d, BigInteger)      
    Console.WriteLine(assignedFromDecimal)
    ' The example displays the following output:
    '   179032
    '   64312      
    

這些方法可讓您具現化BigInteger物件,其值為其中一個現有的數字的範圍中的類型才。These methods enable you to instantiate a BigInteger object whose value is in the range of one of the existing numeric types only. 您可以具現化BigInteger物件,其值可能會超過三種方式之一中的現有數值類型的範圍:You can instantiate a BigInteger object whose value can exceed the range of the existing numeric types in one of three ways:

  • 您可以使用new關鍵字,並提供任何大小的位元組陣列BigInteger.BigInteger建構函式。You can use the new keyword and provide a byte array of any size to the BigInteger.BigInteger constructor. 例如:For example:

    byte[] byteArray = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
    BigInteger newBigInt = new BigInteger(byteArray);
    Console.WriteLine("The value of newBigInt is {0} (or 0x{0:x}).", newBigInt);    
    // The example displays the following output:
    //   The value of newBigInt is 4759477275222530853130 (or 0x102030405060708090a).
    
    Dim byteArray() As Byte = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
    Dim newBigInt As New BigInteger(byteArray)
    Console.WriteLine("The value of newBigInt is {0} (or 0x{0:x}).", newBigInt)    
    ' The example displays the following output:
    '   The value of newBigInt is 4759477275222530853130 (or 0x102030405060708090a).
    
  • 您可以呼叫Parse或是TryParse方法,將轉換的數字的字串表示BigIntegerYou can call the Parse or TryParse methods to convert the string representation of a number to a BigInteger. 例如:For example:

    string positiveString = "91389681247993671255432112000000";
    string negativeString = "-90315837410896312071002088037140000";
    BigInteger posBigInt = 0;
    BigInteger negBigInt = 0;
    
    try {
       posBigInt = BigInteger.Parse(positiveString);
       Console.WriteLine(posBigInt);
    }
    catch (FormatException)
    {
       Console.WriteLine("Unable to convert the string '{0}' to a BigInteger value.", 
                         positiveString);
    }
    
    if (BigInteger.TryParse(negativeString, out negBigInt))
      Console.WriteLine(negBigInt);
    else
       Console.WriteLine("Unable to convert the string '{0}' to a BigInteger value.", 
                          negativeString);
    
    // The example displays the following output:
    //   9.1389681247993671255432112E+31
    //   -9.0315837410896312071002088037E+34
    
    Dim positiveString As String = "91389681247993671255432112000000"
    Dim negativeString As string = "-90315837410896312071002088037140000"
    Dim posBigInt As BigInteger = 0
    Dim negBigInt As BigInteger = 0
    
    Try
       posBigInt = BigInteger.Parse(positiveString)
       Console.WriteLine(posBigInt)
    Catch e As FormatException
       Console.WriteLine("Unable to convert the string '{0}' to a BigInteger value.", _
                         positiveString)
    End Try
    
    If BigInteger.TryParse(negativeString, negBigInt) Then
      Console.WriteLine(negBigInt)
    Else
       Console.WriteLine("Unable to convert the string '{0}' to a BigInteger value.", _
                          negativeString)
    End If         
    ' The example displays the following output:
    '   9.1389681247993671255432112E+31
    '   -9.0315837410896312071002088037E+34
    
  • 您可以呼叫static(Shared Visual Basic 中)BigInteger方法,執行數值運算式上的某項作業,並傳回導出BigInteger結果。You can call a static (Shared in Visual Basic) BigInteger method that performs some operation on a numeric expression and returns a calculated BigInteger result. 下列範例會藉由 cubeUInt64.MaxValue並指派結果BigIntegerThe following example does this by cubing UInt64.MaxValue and assigning the result to a BigInteger.

    BigInteger number = BigInteger.Pow(UInt64.MaxValue, 3);
    Console.WriteLine(number);
    // The example displays the following output:
    //    6277101735386680762814942322444851025767571854389858533375
    
    Dim number As BigInteger = BigInteger.Pow(UInt64.MaxValue, 3)
    Console.WriteLine(number)
    ' The example displays the following output:
      ' 6277101735386680762814942322444851025767571854389858533375
    

未初始化的值BigIntegerZeroThe uninitialized value of a BigInteger is Zero.

BigInteger 值上執行的作業Performing Operations on BigInteger Values

您可以使用BigInteger像您使用任何其他整數類資料類型執行個體。You can use a BigInteger instance as you would use any other integral type. BigInteger 可讓您執行基本數學運算,例如加法、 減法、 部門、 乘法、 減法、 負號、 和一元負運算的標準數值運算子會多載。BigInteger overloads the standard numeric operators to enable you to perform basic mathematical operations such as addition, subtraction, division, multiplication, subtraction, negation, and unary negation. 您也可以使用標準數值運算子比較兩個BigInteger彼此的值。You can also use the standard numeric operators to compare two BigInteger values with each other. 像其他整數類資料類型,BigInteger也支援 位元AndOrXOr,左 shift 鍵和向右移位運算子。Like the other integral types, BigInteger also supports the bitwise And, Or, XOr, left shift, and right shift operators. 語言不支援自訂運算子BigInteger結構也會提供用於執行數學運算的對等方法。For languages that do not support custom operators, the BigInteger structure also provides equivalent methods for performing mathematical operations. 其中包括AddDivideMultiplyNegateSubtract,和其他許多選項。These include Add, Divide, Multiply, Negate, Subtract, and several others.

許多成員的BigInteger結構會直接對應至整數類資料類型的成員。Many members of the BigInteger structure correspond directly to members of the other integral types. 颾魤 ㄛBigInteger新增成員,如下所示:In addition, BigInteger adds members such as the following:

許多這些額外的成員對應至的成員Math類別,可提供基本數值類型所使用的功能。Many of these additional members correspond to the members of the Math class, which provides the functionality to work with the primitive numeric types.

可變動性和 BigInteger 結構Mutability and the BigInteger Structure

下列範例會具現化BigInteger物件,然後逐一遞增其值。The following example instantiates a BigInteger object and then increments its value by one.

BigInteger number = BigInteger.Multiply(Int64.MaxValue, 3);
number++;
Console.WriteLine(number);
Dim number As BigInteger = BigInteger.Multiply(Int64.MaxValue, 3)
number += 1
Console.WriteLine(number)

雖然此範例中會出現來修改現有值,但這不是物件的如此。Although this example appears to modify the value of the existing object, this is not the case. BigInteger 物件是不可變的這表示在內部,common language runtime 實際上會建立新BigInteger物件,並將其指派的值大於其先前的值。BigInteger objects are immutable, which means that internally, the common language runtime actually creates a new BigInteger object and assigns it a value one greater than its previous value. 然後會將這個新物件傳回給呼叫者。This new object is then returned to the caller.

注意

.NET Framework 中的其他數值類型也是不可變的。The other numeric types in the .NET Framework are also immutable. 不過,因為BigInteger類型沒有沒有上限或下限的界限,其值可以變得非常大,對效能造成可觀的衝擊。However, because the BigInteger type has no upper or lower bounds, its values can grow extremely large and have a measurable impact on performance.

雖然此程序是呼叫端透明的就會產生對效能帶來負面影響。Although this process is transparent to the caller, it does incur a performance penalty. 在某些情況下,尤其是當重複的作業將會在迴圈中上非常大BigInteger值,該效能產生負面影響可能更為顯著。In some cases, especially when repeated operations are performed in a loop on very large BigInteger values, that performance penalty can be significant. 例如,在下列範例中,作業回應達百萬次和BigInteger值都會加一每次作業成功。For example, in the following example, an operation is performed repetitively up to a million times, and a BigInteger value is incremented by one every time the operation succeeds.

BigInteger number = Int64.MaxValue ^ 5;
int repetitions = 1000000;
// Perform some repetitive operation 1 million times.
for (int ctr = 0; ctr <= repetitions; ctr++)
{
   // Perform some operation. If it fails, exit the loop.
   if (! SomeOperationSucceeds()) break;
   // The following code executes if the operation succeeds.
   number++;
}
Dim number As BigInteger = Int64.MaxValue ^ 5
Dim repetitions As Integer = 1000000
' Perform some repetitive operation 1 million times.
For ctr As Integer = 0 To repetitions
   ' Perform some operation. If it fails, exit the loop.
   If Not SomeOperationSucceeds() Then Exit For
   ' The following code executes if the operation succeeds.
   number += 1
Next

在此情況下,您可以改善效能,藉由執行的所有中繼指派Int32變數。In such a case, you can improve performance by performing all intermediate assignments to an Int32 variable. 最後一個變數的值再指派給BigInteger迴圈結束時的物件。The final value of the variable can then be assigned to the BigInteger object when the loop exits. 下列範例提供一個實例。The following example provides an illustration.

BigInteger number = Int64.MaxValue ^ 5;
int repetitions = 1000000;
int actualRepetitions = 0;
// Perform some repetitive operation 1 million times.
for (int ctr = 0; ctr <= repetitions; ctr++)
{
   // Perform some operation. If it fails, exit the loop.
   if (! SomeOperationSucceeds()) break;
   // The following code executes if the operation succeeds.
   actualRepetitions++;
}
number += actualRepetitions;
Dim number As BigInteger = Int64.MaxValue ^ 5
Dim repetitions As Integer = 1000000
Dim actualRepetitions As Integer = 0
' Perform some repetitive operation 1 million times.
For ctr As Integer = 0 To repetitions
   ' Perform some operation. If it fails, exit the loop.
   If Not SomeOperationSucceeds() Then Exit For
   ' The following code executes if the operation succeeds.
   actualRepetitions += 1
Next
number += actualRepetitions

使用位元組陣列與十六進位字串Working with Byte Arrays and Hexadecimal Strings

如果您將轉換BigInteger值為位元組陣列,或如果您將轉換的位元組陣列,以BigInteger值,您必須考慮的位元組順序。If you convert BigInteger values to byte arrays, or if you convert byte arrays to BigInteger values, you must consider the order of bytes. BigInteger結構會預期要有個別的位元組才會出現在 little-endian 順序的位元組陣列 (也就是低序位位元組值的前面的高序位位元組)。The BigInteger structure expects the individual bytes in a byte array to appear in little-endian order (that is, the lower-order bytes of the value precede the higher-order bytes). 您可以往返BigInteger值,藉由呼叫ToByteArray方法,然後再將傳遞產生的位元組陣列BigInteger(Byte[])建構函式,如下列範例所示。You can round-trip a BigInteger value by calling the ToByteArray method and then passing the resulting byte array to the BigInteger(Byte[]) constructor, as the following example shows.

BigInteger number = BigInteger.Pow(Int64.MaxValue, 2);     
Console.WriteLine(number);

// Write the BigInteger value to a byte array.
byte[] bytes = number.ToByteArray();

// Display the byte array.
foreach (byte byteValue in bytes)
   Console.Write("0x{0:X2} ", byteValue);
Console.WriteLine();

// Restore the BigInteger value from a Byte array.
BigInteger newNumber = new BigInteger(bytes);
Console.WriteLine(newNumber);
// The example displays the following output:
//    8.5070591730234615847396907784E+37
//    0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x3F
//    
//    8.5070591730234615847396907784E+37
Dim number As BigInteger = BigInteger.Pow(Int64.MaxValue, 2)     
Console.WriteLine(number)

' Write the BigInteger value to a byte array.
Dim bytes() As Byte = number.ToByteArray()

' Display the byte array.
For Each byteValue As Byte In bytes
   Console.Write("0x{0:X2} ", byteValue)
Next   
Console.WriteLine()

' Restore the BigInteger value from a Byte array.
Dim newNumber As BigInteger = New BigInteger(bytes)
Console.WriteLine(newNumber)               
' The example displays the following output:
'    8.5070591730234615847396907784E+37
'    0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x3F
'    
'    8.5070591730234615847396907784E+37

若要具現化BigInteger值,您可以從位元組陣列,代表某些其他整數類資料類型的值,傳遞將整數值BitConverter.GetBytes方法,然後再產生的位元組陣列的傳遞BigInteger(Byte[])建構函式。To instantiate a BigInteger value from a byte array that represents a value of some other integral type, you can pass the integral value to the BitConverter.GetBytes method, and then pass the resulting byte array to the BigInteger(Byte[]) constructor. 下列範例會具現化BigInteger值從位元組陣列,表示Int16值。The following example instantiates a BigInteger value from a byte array that represents an Int16 value.

short originalValue = 30000;
Console.WriteLine(originalValue);

// Convert the Int16 value to a byte array.
byte[] bytes = BitConverter.GetBytes(originalValue);

// Display the byte array.
foreach (byte byteValue in bytes)
   Console.Write("0x{0} ", byteValue.ToString("X2"));
Console.WriteLine();

// Pass byte array to the BigInteger constructor.
BigInteger number = new BigInteger(bytes);
Console.WriteLine(number);
// The example displays the following output:
//       30000
//       0x30 0x75
//       30000
Dim originalValue As Short = 30000
Console.WriteLine(originalValue)

' Convert the Int16 value to a byte array.
Dim bytes() As Byte = BitConverter.GetBytes(originalValue)

' Display the byte array.
For Each byteValue As Byte In bytes
   Console.Write("0x{0} ", byteValue.ToString("X2"))
Next    
Console.WriteLine() 

' Pass byte array to the BigInteger constructor.
Dim number As BigInteger = New BigInteger(bytes)
Console.WriteLine(number)
' The example displays the following output:
'       30000
'       0x30 0x75
'       30000

BigInteger結構假設,負值會儲存使用二補數表示。The BigInteger structure assumes that negative values are stored by using two's complement representation. 因為BigInteger結構代表數值,但是沒有固定的長度,BigInteger(Byte[])建構函式一律會解譯為正負號位元陣列中的最後一個位元組的最大顯著性位元。Because the BigInteger structure represents a numeric value with no fixed length, the BigInteger(Byte[]) constructor always interprets the most significant bit of the last byte in the array as a sign bit. 若要避免BigInteger(Byte[])從令人困惑的二補數表示負值正值,正值的正負號和大小表示的建構函式中的值的最高有效位元的位元組陣列中的最後一個位元組一般被視為集合應該包含額外的位元組,其值為 0。To prevent the BigInteger(Byte[]) constructor from confusing the two's complement representation of a negative value with the sign and magnitude representation of a positive value, positive values in which the most significant bit of the last byte in the byte array would ordinarily be set should include an additional byte whose value is 0. 比方說,0xC0 0xBD 0xF0 0xFF 是-1,000,000 或 4,293,967,296 由小到大十六進位表示法。For example, 0xC0 0xBD 0xF0 0xFF is the little-endian hexadecimal representation of either -1,000,000 or 4,293,967,296. 因為此陣列中的最後一個位元組的最大顯著性位元上,會由解譯的位元組陣列值BigInteger(Byte[])-1,000,000 為建構函式。Because the most significant bit of the last byte in this array is on, the value of the byte array would be interpreted by the BigInteger(Byte[]) constructor as -1,000,000. 若要具現化BigInteger其值為正數,位元組陣列,其元素為 0xC0 0xBD 0xF0 0xFF 0x00 必須傳遞給建構函式。To instantiate a BigInteger whose value is positive, a byte array whose elements are 0xC0 0xBD 0xF0 0xFF 0x00 must be passed to the constructor. 下列範例將說明這點。The following example illustrates this.

int negativeNumber = -1000000;
uint positiveNumber = 4293967296;

byte[] negativeBytes = BitConverter.GetBytes(negativeNumber); 
BigInteger negativeBigInt = new BigInteger(negativeBytes);
Console.WriteLine(negativeBigInt.ToString("N0"));

byte[] tempPosBytes = BitConverter.GetBytes(positiveNumber);
byte[] positiveBytes = new byte[tempPosBytes.Length + 1];
Array.Copy(tempPosBytes, positiveBytes, tempPosBytes.Length);
BigInteger positiveBigInt = new BigInteger(positiveBytes);
Console.WriteLine(positiveBigInt.ToString("N0")); 
// The example displays the following output:
//    -1,000,000
//    4,293,967,296      
Dim negativeNumber As Integer = -1000000
Dim positiveNumber As UInteger = 4293967296

Dim negativeBytes() As Byte = BitConverter.GetBytes(negativeNumber) 
Dim negativeBigInt As New BigInteger(negativeBytes)
Console.WriteLine(negativeBigInt.ToString("N0"))

Dim tempPosBytes() As Byte = BitConverter.GetBytes(positiveNumber)
Dim positiveBytes(tempposBytes.Length) As Byte
Array.Copy(tempPosBytes, positiveBytes, tempPosBytes.Length)
Dim positiveBigInt As New BigInteger(positiveBytes)
Console.WriteLine(positiveBigInt.ToString("N0")) 
' The example displays the following output:
'    -1,000,000
'    4,293,967,296      

所建立的位元組陣列ToByteArray正值方法包含此額外的零值的位元組。Byte arrays created by the ToByteArray method from positive values include this extra zero-value byte. 因此,BigInteger結構可以成功地反覆存取值所指派,然後將它們還原從位元組陣列,如下列範例所示。Therefore, the BigInteger structure can successfully round-trip values by assigning them to, and then restoring them from, byte arrays, as the following example shows.

BigInteger positiveValue = 15777216;
BigInteger negativeValue  = -1000000;

Console.WriteLine("Positive value: " + positiveValue.ToString("N0"));
byte[] bytes = positiveValue.ToByteArray();

foreach (byte byteValue in bytes)
   Console.Write("{0:X2} ", byteValue);
Console.WriteLine();
positiveValue = new BigInteger(bytes);
Console.WriteLine("Restored positive value: " + positiveValue.ToString("N0"));

Console.WriteLine();
   
Console.WriteLine("Negative value: " + negativeValue.ToString("N0"));
bytes = negativeValue.ToByteArray();
foreach (byte byteValue in bytes)
   Console.Write("{0:X2} ", byteValue);
Console.WriteLine();
negativeValue = new BigInteger(bytes);
Console.WriteLine("Restored negative value: " + negativeValue.ToString("N0"));
// The example displays the following output:
//       Positive value: 15,777,216
//       C0 BD F0 00
//       Restored positive value: 15,777,216
//       
//       Negative value: -1,000,000
//       C0 BD F0
//       Restored negative value: -1,000,000
Dim positiveValue As BigInteger = 15777216
Dim negativeValue As BigInteger = -1000000

Console.WriteLine("Positive value: " + positiveValue.ToString("N0"))
Dim bytes() As Byte = positiveValue.ToByteArray()
For Each byteValue As Byte In bytes
   Console.Write("{0:X2} ", byteValue)
Next
Console.WriteLine()
positiveValue = New BigInteger(bytes)
Console.WriteLine("Restored positive value: " + positiveValue.ToString("N0"))

Console.WriteLine()
   
Console.WriteLIne("Negative value: " + negativeValue.ToString("N0"))
bytes = negativeValue.ToByteArray()
For Each byteValue As Byte In bytes
   Console.Write("{0:X2} ", byteValue)
Next
Console.WriteLine()
negativeValue = New BigInteger(bytes)
Console.WriteLine("Restored negative value: " + negativeValue.ToString("N0"))
' The example displays the following output:
'       Positive value: 15,777,216
'       C0 BD F0 00
'       Restored positive value: 15,777,216
'       
'       Negative value: -1,000,000
'       C0 BD F0
'       Restored negative value: -1,000,000

不過,您可能需要將此額外的零值位元組至位元組陣列,動態地建立開發人員,或將不帶正負號的整數轉換成位元組陣列的方法所傳回的 (例如BitConverter.GetBytes(UInt16)BitConverter.GetBytes(UInt32),和BitConverter.GetBytes(UInt64))。However, you may need to add this additional zero-value byte to byte arrays that are created dynamically by the developer or that are returned by methods that convert unsigned integers to byte arrays (such as BitConverter.GetBytes(UInt16), BitConverter.GetBytes(UInt32), and BitConverter.GetBytes(UInt64)).

剖析十六進位的字串,當BigInteger.Parse(String, NumberStyles)BigInteger.Parse(String, NumberStyles, IFormatProvider)方法會假設,如果字串中的第一個位元組的最大顯著性位元設定,或如果字串的第一個十六進位數字表示較低的四位元的位元組值,這個值是表示使用二補數表示。When parsing a hexadecimal string, the BigInteger.Parse(String, NumberStyles) and BigInteger.Parse(String, NumberStyles, IFormatProvider) methods assume that if the most significant bit of the first byte in the string is set, or if the first hexadecimal digit of the string represents the lower four bits of a byte value, the value is represented by using two's complement representation. 例如,"FF01"和"F01 」 代表-255 的十進位值。For example, both "FF01" and "F01" represent the decimal value -255. 若要區分正從負數值,正值應該包含前置零。To differentiate positive from negative values, positive values should include a leading zero. 相關的多載ToString方法,傳遞"X"格式字串時加入前置零的正數值傳回十六進位的字串。The relevant overloads of the ToString method, when they are passed the "X" format string, add a leading zero to the returned hexadecimal string for positive values. 這使得來回BigInteger使用的值ToStringParse方法,如下列範例所示。This makes it possible to round-trip BigInteger values by using the ToString and Parse methods, as the following example shows.

BigInteger negativeNumber = -1000000;
BigInteger positiveNumber  = 15777216;

string negativeHex = negativeNumber.ToString("X");
string positiveHex = positiveNumber.ToString("X");

BigInteger negativeNumber2, positiveNumber2;  
negativeNumber2 = BigInteger.Parse(negativeHex, 
                                   NumberStyles.HexNumber);
positiveNumber2 = BigInteger.Parse(positiveHex,
                                   NumberStyles.HexNumber);

Console.WriteLine("Converted {0:N0} to {1} back to {2:N0}.", 
                   negativeNumber, negativeHex, negativeNumber2);                                         
Console.WriteLine("Converted {0:N0} to {1} back to {2:N0}.", 
                   positiveNumber, positiveHex, positiveNumber2);                                         
// The example displays the following output:
//       Converted -1,000,000 to F0BDC0 back to -1,000,000.
//       Converted 15,777,216 to 0F0BDC0 back to 15,777,216.
Dim negativeNumber As BigInteger = -1000000
Dim positiveNumber As BigInteger = 15777216

Dim negativeHex As String = negativeNumber.ToString("X")
Dim positiveHex As string = positiveNumber.ToString("X")

Dim negativeNumber2, positiveNumber2 As BigInteger 
negativeNumber2 = BigInteger.Parse(negativeHex, 
                                   NumberStyles.HexNumber)
positiveNumber2 = BigInteger.Parse(positiveHex,
                                   NumberStyles.HexNumber)

Console.WriteLine("Converted {0:N0} to {1} back to {2:N0}.", 
                   negativeNumber, negativeHex, negativeNumber2)                                         
Console.WriteLine("Converted {0:N0} to {1} back to {2:N0}.", 
                   positiveNumber, positiveHex, positiveNumber2)                                         
' The example displays the following output:
'       Converted -1,000,000 to F0BDC0 back to -1,000,000.
'       Converted 15,777,216 to 0F0BDC0 back to 15,777,216.

不過,將十六進位字串建立藉由呼叫ToString其他整數型別或多載的方法ToString方法,包括toBase參數並不表示正負號的值或從其來源資料類型衍生的十六進位字串。However, the hexadecimal strings created by calling the ToString methods of the other integral types or the overloads of the ToString method that include a toBase parameter do not indicate the sign of the value or the source data type from which the hexadecimal string was derived. 已成功具現化BigInteger從這類字串的值需要某些額外邏輯。Successfully instantiating a BigInteger value from such a string requires some additional logic. 下列範例提供一個可能的實作。The following example provides one possible implementation.

using System;
using System.Globalization;
using System.Numerics;

public struct HexValue
{
   public int Sign;
   public string Value;
}

public class Example
{
   public static void Main()
   {
      uint positiveNumber = 4039543321;
      int negativeNumber = -255423975;

      // Convert the numbers to hex strings.
      HexValue hexValue1, hexValue2;
      hexValue1.Value = positiveNumber.ToString("X");
      hexValue1.Sign = Math.Sign(positiveNumber);
      
      hexValue2.Value = Convert.ToString(negativeNumber, 16);
      hexValue2.Sign = Math.Sign(negativeNumber);
      
      // Round-trip the hexadecimal values to BigInteger values.
      string hexString;
      BigInteger positiveBigInt, negativeBigInt;
      
      hexString = (hexValue1.Sign == 1 ? "0" : "") + hexValue1.Value;
      positiveBigInt = BigInteger.Parse(hexString, NumberStyles.HexNumber);      
      Console.WriteLine("Converted {0} to {1} and back to {2}.", 
                        positiveNumber, hexValue1.Value, positiveBigInt);

      hexString = (hexValue2.Sign == 1 ? "0" : "") + hexValue2.Value;
      negativeBigInt = BigInteger.Parse(hexString, NumberStyles.HexNumber);      
      Console.WriteLine("Converted {0} to {1} and back to {2}.", 
                        negativeNumber, hexValue2.Value, negativeBigInt);
   }
}
// The example displays the following output:
//       Converted 4039543321 to F0C68A19 and back to 4039543321.
//       Converted -255423975 to f0c68a19 and back to -255423975.
Imports System.Globalization
Imports System.Numerics

Public Structure HexValue
   Public Sign As Integer
   Public Value As String
End Structure
   
Module Example
   Public Sub Main()
      Dim positiveNumber As UInteger = 4039543321
      Dim negativeNumber As Integer = -255423975

      ' Convert the numbers to hex strings.
      Dim hexValue1, hexValue2 As HexValue
      hexValue1.Value = positiveNumber.ToString("X")
      hexValue1.Sign = Math.Sign(positiveNumber)
      
      hexValue2.Value = Convert.ToString(negativeNumber, 16)
      hexValue2.Sign = Math.Sign(negativeNumber)
      
      ' Round-trip the hexadecimal values to BigInteger values.
      Dim hexString As String
      Dim positiveBigInt, negativeBigInt As BigInteger
      
      hexString = CStr(IIf(hexValue1.Sign = 1, "0", "")) + hexValue1.Value
      positiveBigInt = BigInteger.Parse(hexString, NumberStyles.HexNumber)      
      Console.WriteLine("Converted {0} to {1} and back to {2}.", 
                        positiveNumber, hexValue1.Value, positiveBigInt)

      hexString = CStr(IIf(hexValue2.Sign = 1, "0", "")) + hexValue2.Value
      negativeBigInt = BigInteger.Parse(hexString, NumberStyles.HexNumber)      
      Console.WriteLine("Converted {0} to {1} and back to {2}.", 
                        negativeNumber, hexValue2.Value, negativeBigInt)

   End Sub
End Module
' The example displays the following output:
'       Converted 4039543321 to F0C68A19 and back to 4039543321.
'       Converted -255423975 to f0c68a19 and back to -255423975.

建構函式

BigInteger(Byte[]) BigInteger(Byte[]) BigInteger(Byte[]) BigInteger(Byte[])

使用位元組陣列中的值,初始化 BigInteger 結構的新執行個體。Initializes a new instance of the BigInteger structure using the values in a byte array.

BigInteger(Decimal) BigInteger(Decimal) BigInteger(Decimal) BigInteger(Decimal)

使用 BigInteger 值,初始化 Decimal 結構的新執行個體。Initializes a new instance of the BigInteger structure using a Decimal value.

BigInteger(Double) BigInteger(Double) BigInteger(Double) BigInteger(Double)

使用雙精確度浮點值,初始化 BigInteger 結構的新執行個體。Initializes a new instance of the BigInteger structure using a double-precision floating-point value.

BigInteger(Int32) BigInteger(Int32) BigInteger(Int32) BigInteger(Int32)

使用 32 位元帶正負號的整數值,初始化 BigInteger 結構的新執行個體。Initializes a new instance of the BigInteger structure using a 32-bit signed integer value.

BigInteger(Int64) BigInteger(Int64) BigInteger(Int64) BigInteger(Int64)

使用 64 位元帶正負號的整數值,初始化 BigInteger 結構的新執行個體。Initializes a new instance of the BigInteger structure using a 64-bit signed integer value.

BigInteger(Single) BigInteger(Single) BigInteger(Single) BigInteger(Single)

使用單精確度浮點值,初始化 BigInteger 結構的新執行個體。Initializes a new instance of the BigInteger structure using a single-precision floating-point value.

BigInteger(UInt32) BigInteger(UInt32) BigInteger(UInt32) BigInteger(UInt32)

使用不帶正負號的 32 位元整數值,初始化 BigInteger 結構的新執行個體。Initializes a new instance of the BigInteger structure using an unsigned 32-bit integer value.

BigInteger(UInt64) BigInteger(UInt64) BigInteger(UInt64) BigInteger(UInt64)

使用不帶正負號的 64 位元整數值,初始化 BigInteger 結構的新執行個體。Initializes a new instance of the BigInteger structure with an unsigned 64-bit integer value.

BigInteger(ReadOnlySpan<Byte>, Boolean, Boolean) BigInteger(ReadOnlySpan<Byte>, Boolean, Boolean) BigInteger(ReadOnlySpan<Byte>, Boolean, Boolean) BigInteger(ReadOnlySpan<Byte>, Boolean, Boolean)

屬性

IsEven IsEven IsEven IsEven

表示目前 BigInteger 物件的值是否為偶數。Indicates whether the value of the current BigInteger object is an even number.

IsOne IsOne IsOne IsOne

表示目前 BigInteger 物件的值是否為 OneIndicates whether the value of the current BigInteger object is One.

IsPowerOfTwo IsPowerOfTwo IsPowerOfTwo IsPowerOfTwo

表示目前 BigInteger 物件的值是否為二乘冪。Indicates whether the value of the current BigInteger object is a power of two.

IsZero IsZero IsZero IsZero

表示目前 BigInteger 物件的值是否為 ZeroIndicates whether the value of the current BigInteger object is Zero.

MinusOne MinusOne MinusOne MinusOne

取得表示數字負一 (-1) 的值。Gets a value that represents the number negative one (-1).

One One One One

取得表示數字一 (1) 的值。Gets a value that represents the number one (1).

Sign Sign Sign Sign

取得數字,這個數字表示目前 BigInteger 物件的正負號 (負數、正數或零)。Gets a number that indicates the sign (negative, positive, or zero) of the current BigInteger object.

Zero Zero Zero Zero

取得表示數字 0 (零) 的值。Gets a value that represents the number 0 (zero).

方法

Abs(BigInteger) Abs(BigInteger) Abs(BigInteger) Abs(BigInteger)

取得 BigInteger 物件的絕對值。Gets the absolute value of a BigInteger object.

Add(BigInteger, BigInteger) Add(BigInteger, BigInteger) Add(BigInteger, BigInteger) Add(BigInteger, BigInteger)

兩個 BigInteger 值相加,並傳回結果。Adds two BigInteger values and returns the result.

Compare(BigInteger, BigInteger) Compare(BigInteger, BigInteger) Compare(BigInteger, BigInteger) Compare(BigInteger, BigInteger)

比較兩個 BigInteger 值並傳回整數,這個整數表示第一個值小於、等於或大於第二個值。Compares two BigInteger values and returns an integer that indicates whether the first value is less than, equal to, or greater than the second value.

CompareTo(Object) CompareTo(Object) CompareTo(Object) CompareTo(Object)

比較這個執行個體與特定物件,並且傳回一個整數,指出這個執行個體的值是小於、等於或大於特定物件的值。Compares this instance to a specified object and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified object.

CompareTo(UInt64) CompareTo(UInt64) CompareTo(UInt64) CompareTo(UInt64)

比較這個執行個體與不帶正負號的 64 位元整數,並且傳回整數,這個整數表示這個執行個體的值小於、等於或大於不帶正負號 64 位元整數的值。Compares this instance to an unsigned 64-bit integer and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the unsigned 64-bit integer.

CompareTo(Int64) CompareTo(Int64) CompareTo(Int64) CompareTo(Int64)

比較這個執行個體與帶正負號的 64 位元整數,並且傳回整數,這個整數表示這個執行個體的值小於、等於或大於帶正負號 64 位元整數的值。Compares this instance to a signed 64-bit integer and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the signed 64-bit integer.

CompareTo(BigInteger) CompareTo(BigInteger) CompareTo(BigInteger) CompareTo(BigInteger)

比較這個執行個體與第二個 BigInteger,並且傳回整數,這個整數表示這個執行個體的值小於、等於或大於指定之物件的值。Compares this instance to a second BigInteger and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified object.

Divide(BigInteger, BigInteger) Divide(BigInteger, BigInteger) Divide(BigInteger, BigInteger) Divide(BigInteger, BigInteger)

某個 BigInteger 值除以另一個值,並且傳回結果。Divides one BigInteger value by another and returns the result.

DivRem(BigInteger, BigInteger, BigInteger) DivRem(BigInteger, BigInteger, BigInteger) DivRem(BigInteger, BigInteger, BigInteger) DivRem(BigInteger, BigInteger, BigInteger)

某個 BigInteger 值除以另一個值,傳回結果,並在輸出參數中傳回餘數。Divides one BigInteger value by another, returns the result, and returns the remainder in an output parameter.

Equals(Int64) Equals(Int64) Equals(Int64) Equals(Int64)

傳回值,這個值表示目前執行個體與帶正負號的 64 位元整數是否有相同的值。Returns a value that indicates whether the current instance and a signed 64-bit integer have the same value.

Equals(BigInteger) Equals(BigInteger) Equals(BigInteger) Equals(BigInteger)

傳回值,這個值表示目前執行個體與指定的 BigInteger 物件是否有相同的值。Returns a value that indicates whether the current instance and a specified BigInteger object have the same value.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

傳回值,這個值表示目前執行個體與指定的物件是否有相同的值。Returns a value that indicates whether the current instance and a specified object have the same value.

Equals(UInt64) Equals(UInt64) Equals(UInt64) Equals(UInt64)

傳回值,這個值表示目前執行個體與不帶正負號的 64 位元整數是否有相同的值。Returns a value that indicates whether the current instance and an unsigned 64-bit integer have the same value.

GetByteCount(Boolean) GetByteCount(Boolean) GetByteCount(Boolean) GetByteCount(Boolean)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

傳回目前 BigInteger 物件的雜湊碼。Returns the hash code for the current BigInteger object.

GreatestCommonDivisor(BigInteger, BigInteger) GreatestCommonDivisor(BigInteger, BigInteger) GreatestCommonDivisor(BigInteger, BigInteger) GreatestCommonDivisor(BigInteger, BigInteger)

求兩個 BigInteger 值的最大公因數。Finds the greatest common divisor of two BigInteger values.

Log(BigInteger) Log(BigInteger) Log(BigInteger) Log(BigInteger)

傳回指定數字的自然 (底數為 e) 對數。Returns the natural (base e) logarithm of a specified number.

Log(BigInteger, Double) Log(BigInteger, Double) Log(BigInteger, Double) Log(BigInteger, Double)

傳回指定底數中指定數字的對數。Returns the logarithm of a specified number in a specified base.

Log10(BigInteger) Log10(BigInteger) Log10(BigInteger) Log10(BigInteger)

傳回指定數字的以 10 為底數的對數。Returns the base 10 logarithm of a specified number.

Max(BigInteger, BigInteger) Max(BigInteger, BigInteger) Max(BigInteger, BigInteger) Max(BigInteger, BigInteger)

傳回兩個 BigInteger 值的較大值。Returns the larger of two BigInteger values.

Min(BigInteger, BigInteger) Min(BigInteger, BigInteger) Min(BigInteger, BigInteger) Min(BigInteger, BigInteger)

傳回兩個 BigInteger 值的較小值。Returns the smaller of two BigInteger values.

ModPow(BigInteger, BigInteger, BigInteger) ModPow(BigInteger, BigInteger, BigInteger) ModPow(BigInteger, BigInteger, BigInteger) ModPow(BigInteger, BigInteger, BigInteger)

一個數目自乘至另一個數目的乘冪後,執行模數除法。Performs modulus division on a number raised to the power of another number.

Multiply(BigInteger, BigInteger) Multiply(BigInteger, BigInteger) Multiply(BigInteger, BigInteger) Multiply(BigInteger, BigInteger)

傳回兩個 BigInteger 值的乘積。Returns the product of two BigInteger values.

Negate(BigInteger) Negate(BigInteger) Negate(BigInteger) Negate(BigInteger)

將指定的 BigInteger 值變換正負號。Negates a specified BigInteger value.

Parse(String) Parse(String) Parse(String) Parse(String)

將數字的字串表示,轉換為其相等的 BigIntegerConverts the string representation of a number to its BigInteger equivalent.

Parse(String, NumberStyles) Parse(String, NumberStyles) Parse(String, NumberStyles) Parse(String, NumberStyles)

將指定樣式中數字的字串表示轉換為其相等的 BigIntegerConverts the string representation of a number in a specified style to its BigInteger equivalent.

Parse(String, IFormatProvider) Parse(String, IFormatProvider) Parse(String, IFormatProvider) Parse(String, IFormatProvider)

將使用指定特定文化特性格式之數字的字串表示轉換為其相等的 BigIntegerConverts the string representation of a number in a specified culture-specific format to its BigInteger equivalent.

Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider) Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider) Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider) Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)
Parse(String, NumberStyles, IFormatProvider) Parse(String, NumberStyles, IFormatProvider) Parse(String, NumberStyles, IFormatProvider) Parse(String, NumberStyles, IFormatProvider)

將數字的字串表示 (使用指定樣式和特定文化特性的格式) 轉換為其相等的 BigIntegerConverts the string representation of a number in a specified style and culture-specific format to its BigInteger equivalent.

Pow(BigInteger, Int32) Pow(BigInteger, Int32) Pow(BigInteger, Int32) Pow(BigInteger, Int32)

BigInteger 值自乘至指定之值的乘冪。Raises a BigInteger value to the power of a specified value.

Remainder(BigInteger, BigInteger) Remainder(BigInteger, BigInteger) Remainder(BigInteger, BigInteger) Remainder(BigInteger, BigInteger)

對兩個 BigInteger 值執行整數除法運算,並傳回餘數。Performs integer division on two BigInteger values and returns the remainder.

Subtract(BigInteger, BigInteger) Subtract(BigInteger, BigInteger) Subtract(BigInteger, BigInteger) Subtract(BigInteger, BigInteger)

某個 BigInteger 值減去另一個值,並且傳回結果。Subtracts one BigInteger value from another and returns the result.

ToByteArray() ToByteArray() ToByteArray() ToByteArray()

BigInteger 值轉換成位元組陣列。Converts a BigInteger value to a byte array.

ToByteArray(Boolean, Boolean) ToByteArray(Boolean, Boolean) ToByteArray(Boolean, Boolean) ToByteArray(Boolean, Boolean)
ToString() ToString() ToString() ToString()

將目前 BigInteger 物件的數值,轉換為其相等的字串表示。Converts the numeric value of the current BigInteger object to its equivalent string representation.

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

使用指定的文化特性特定格式資訊,將目前 BigInteger 物件的數值轉換為其對等字串表示。Converts the numeric value of the current BigInteger object to its equivalent string representation by using the specified culture-specific formatting information.

ToString(String) ToString(String) ToString(String) ToString(String)

使用指定的格式,將目前 BigInteger 物件的值,轉換為其相等字串表示。Converts the numeric value of the current BigInteger object to its equivalent string representation by using the specified format.

ToString(String, IFormatProvider) ToString(String, IFormatProvider) ToString(String, IFormatProvider) ToString(String, IFormatProvider)

使用指定的格式和特定文化特性的格式資訊,將目前 BigInteger 物件的數值,轉換為其相等的字串表示。Converts the numeric value of the current BigInteger object to its equivalent string representation by using the specified format and culture-specific format information.

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)
TryParse(ReadOnlySpan<Char>, BigInteger) TryParse(ReadOnlySpan<Char>, BigInteger) TryParse(ReadOnlySpan<Char>, BigInteger) TryParse(ReadOnlySpan<Char>, BigInteger)
TryParse(String, BigInteger) TryParse(String, BigInteger) TryParse(String, BigInteger) TryParse(String, BigInteger)

嘗試將數字的字串表示轉換成其相等的 BigInteger,並傳回一個值表示轉換是否成功。Tries to convert the string representation of a number to its BigInteger equivalent, and returns a value that indicates whether the conversion succeeded.

TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, BigInteger) TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, BigInteger) TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, BigInteger) TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, BigInteger)
TryParse(String, NumberStyles, IFormatProvider, BigInteger) TryParse(String, NumberStyles, IFormatProvider, BigInteger) TryParse(String, NumberStyles, IFormatProvider, BigInteger) TryParse(String, NumberStyles, IFormatProvider, BigInteger)

使用指定的文化特性特定格式資訊和格式樣式,將日期和時間的指定字串表示轉換為其對等的 BigInteger,並傳回值,這個值表示轉換是否成功。Tries to convert the string representation of a number in a specified style and culture-specific format to its BigInteger equivalent, and returns a value that indicates whether the conversion succeeded.

TryWriteBytes(Span<Byte>, Int32, Boolean, Boolean) TryWriteBytes(Span<Byte>, Int32, Boolean, Boolean) TryWriteBytes(Span<Byte>, Int32, Boolean, Boolean) TryWriteBytes(Span<Byte>, Int32, Boolean, Boolean)

運算子

Addition(BigInteger, BigInteger) Addition(BigInteger, BigInteger) Addition(BigInteger, BigInteger) Addition(BigInteger, BigInteger)

兩個指定之 BigInteger 物件的值相加。Adds the values of two specified BigInteger objects.

BitwiseAnd(BigInteger, BigInteger) BitwiseAnd(BigInteger, BigInteger) BitwiseAnd(BigInteger, BigInteger) BitwiseAnd(BigInteger, BigInteger)

對兩個 BigInteger 值執行位元 And 運算。Performs a bitwise And operation on two BigInteger values.

BitwiseOr(BigInteger, BigInteger) BitwiseOr(BigInteger, BigInteger) BitwiseOr(BigInteger, BigInteger) BitwiseOr(BigInteger, BigInteger)

對兩個 BigInteger 值執行位元 Or 運算。Performs a bitwise Or operation on two BigInteger values.

Decrement(BigInteger) Decrement(BigInteger) Decrement(BigInteger) Decrement(BigInteger)

BigInteger 值遞減 1。Decrements a BigInteger value by 1.

Division(BigInteger, BigInteger) Division(BigInteger, BigInteger) Division(BigInteger, BigInteger) Division(BigInteger, BigInteger)

使用整數除法,將指定的 BigInteger 值除以另一個指定的 BigInteger 值。Divides a specified BigInteger value by another specified BigInteger value by using integer division.

Equality(Int64, BigInteger) Equality(Int64, BigInteger) Equality(Int64, BigInteger) Equality(Int64, BigInteger)

傳回值,這個值表示帶正負號長整數值與 BigInteger 值是否相等。Returns a value that indicates whether a signed long integer value and a BigInteger value are equal.

Equality(BigInteger, Int64) Equality(BigInteger, Int64) Equality(BigInteger, Int64) Equality(BigInteger, Int64)

傳回值,這個值表示 BigInteger 值與帶正負號長整數值是否相等。Returns a value that indicates whether a BigInteger value and a signed long integer value are equal.

Equality(BigInteger, BigInteger) Equality(BigInteger, BigInteger) Equality(BigInteger, BigInteger) Equality(BigInteger, BigInteger)

傳回值,這個值表示兩個 BigInteger 物件的值是否相等。Returns a value that indicates whether the values of two BigInteger objects are equal.

Equality(BigInteger, UInt64) Equality(BigInteger, UInt64) Equality(BigInteger, UInt64) Equality(BigInteger, UInt64)

傳回值,這個值表示 BigInteger 值與不帶正負號長整數值是否相等。Returns a value that indicates whether a BigInteger value and an unsigned long integer value are equal.

Equality(UInt64, BigInteger) Equality(UInt64, BigInteger) Equality(UInt64, BigInteger) Equality(UInt64, BigInteger)

傳回值,這個值表示不帶正負號長整數值與 BigInteger 值是否相等。Returns a value that indicates whether an unsigned long integer value and a BigInteger value are equal.

ExclusiveOr(BigInteger, BigInteger) ExclusiveOr(BigInteger, BigInteger) ExclusiveOr(BigInteger, BigInteger) ExclusiveOr(BigInteger, BigInteger)

對兩個 BigInteger 值執行位元互斥 Or (XOr) 運算。Performs a bitwise exclusive Or (XOr) operation on two BigInteger values.

Explicit(Decimal to BigInteger) Explicit(Decimal to BigInteger) Explicit(Decimal to BigInteger) Explicit(Decimal to BigInteger)

定義從 Decimal 物件到 BigInteger 值的明確轉換。Defines an explicit conversion of a Decimal object to a BigInteger value.

Explicit(Double to BigInteger) Explicit(Double to BigInteger) Explicit(Double to BigInteger) Explicit(Double to BigInteger)

定義從 Double 值到 BigInteger 值的明確轉換。Defines an explicit conversion of a Double value to a BigInteger value.

Explicit(BigInteger to Byte) Explicit(BigInteger to Byte) Explicit(BigInteger to Byte) Explicit(BigInteger to Byte)

定義從 BigInteger 物件到不帶正負號位元組值的明確轉換。Defines an explicit conversion of a BigInteger object to an unsigned byte value.

Explicit(BigInteger to Decimal) Explicit(BigInteger to Decimal) Explicit(BigInteger to Decimal) Explicit(BigInteger to Decimal)

定義從 BigInteger 物件到 Decimal 值的明確轉換。Defines an explicit conversion of a BigInteger object to a Decimal value.

Explicit(BigInteger to Double) Explicit(BigInteger to Double) Explicit(BigInteger to Double) Explicit(BigInteger to Double)

定義從 BigInteger 物件到 Double 值的明確轉換。Defines an explicit conversion of a BigInteger object to a Double value.

Explicit(BigInteger to Int16) Explicit(BigInteger to Int16) Explicit(BigInteger to Int16) Explicit(BigInteger to Int16)

定義從 BigInteger 物件到 16 位元帶正負號整數值的明確轉換。Defines an explicit conversion of a BigInteger object to a 16-bit signed integer value.

Explicit(BigInteger to Int32) Explicit(BigInteger to Int32) Explicit(BigInteger to Int32) Explicit(BigInteger to Int32)

定義從 BigInteger 物件到 32 位元帶正負號整數值的明確轉換。Defines an explicit conversion of a BigInteger object to a 32-bit signed integer value.

Explicit(BigInteger to Int64) Explicit(BigInteger to Int64) Explicit(BigInteger to Int64) Explicit(BigInteger to Int64)

定義從 BigInteger 物件到 64 位元帶正負號整數值的明確轉換。Defines an explicit conversion of a BigInteger object to a 64-bit signed integer value.

Explicit(BigInteger to SByte) Explicit(BigInteger to SByte) Explicit(BigInteger to SByte) Explicit(BigInteger to SByte)

定義從 BigInteger 物件到帶正負號 8 位元值的明確轉換。Defines an explicit conversion of a BigInteger object to a signed 8-bit value.

此應用程式開發介面不符合 CLS 標準。This API is not CLS-compliant. 符合規範的替代項目為 Int16The compliant alternative is Int16.

Explicit(BigInteger to Single) Explicit(BigInteger to Single) Explicit(BigInteger to Single) Explicit(BigInteger to Single)

定義從 BigInteger 物件到單精確度浮點值的明確轉換。Defines an explicit conversion of a BigInteger object to a single-precision floating-point value.

Explicit(BigInteger to UInt16) Explicit(BigInteger to UInt16) Explicit(BigInteger to UInt16) Explicit(BigInteger to UInt16)

定義從 BigInteger 物件到不帶正負號 16 位元整數值的明確轉換。Defines an explicit conversion of a BigInteger object to an unsigned 16-bit integer value.

此應用程式開發介面不符合 CLS 標準。This API is not CLS-compliant. 符合規範的替代項目為 Int32The compliant alternative is Int32.

Explicit(BigInteger to UInt32) Explicit(BigInteger to UInt32) Explicit(BigInteger to UInt32) Explicit(BigInteger to UInt32)

定義從 BigInteger 物件到不帶正負號 32 位元整數值的明確轉換。Defines an explicit conversion of a BigInteger object to an unsigned 32-bit integer value.

此應用程式開發介面不符合 CLS 標準。This API is not CLS-compliant. 符合規範的替代項目為 Int64The compliant alternative is Int64.

Explicit(BigInteger to UInt64) Explicit(BigInteger to UInt64) Explicit(BigInteger to UInt64) Explicit(BigInteger to UInt64)

定義從 BigInteger 物件到不帶正負號 64 位元整數值的明確轉換。Defines an explicit conversion of a BigInteger object to an unsigned 64-bit integer value.

此應用程式開發介面不符合 CLS 標準。This API is not CLS-compliant. 符合規範的替代項目為 DoubleThe compliant alternative is Double.

Explicit(Single to BigInteger) Explicit(Single to BigInteger) Explicit(Single to BigInteger) Explicit(Single to BigInteger)

定義從 Single 值到 BigInteger 值的明確轉換。Defines an explicit conversion of a Single value to a BigInteger value.

GreaterThan(UInt64, BigInteger) GreaterThan(UInt64, BigInteger) GreaterThan(UInt64, BigInteger) GreaterThan(UInt64, BigInteger)

傳回值,這個值表示 BigInteger 值是否大於 64 位元不帶正負號的整數。Returns a value that indicates whether a BigInteger value is greater than a 64-bit unsigned integer.

GreaterThan(BigInteger, UInt64) GreaterThan(BigInteger, UInt64) GreaterThan(BigInteger, UInt64) GreaterThan(BigInteger, UInt64)

傳回值,這個值表示 BigInteger 值是否大於 64 位元不帶正負號的整數。Returns a value that indicates whether a BigInteger value is greater than a 64-bit unsigned integer.

GreaterThan(Int64, BigInteger) GreaterThan(Int64, BigInteger) GreaterThan(Int64, BigInteger) GreaterThan(Int64, BigInteger)

傳回值,這個值表示 64 位元帶正負號的整數是否大於 BigInteger 值。Returns a value that indicates whether a 64-bit signed integer is greater than a BigInteger value.

GreaterThan(BigInteger, Int64) GreaterThan(BigInteger, Int64) GreaterThan(BigInteger, Int64) GreaterThan(BigInteger, Int64)

傳回值,這個值表示 BigInteger 是否大於 64 位元帶正負號的整數值。Returns a value that indicates whether a BigInteger is greater than a 64-bit signed integer value.

GreaterThan(BigInteger, BigInteger) GreaterThan(BigInteger, BigInteger) GreaterThan(BigInteger, BigInteger) GreaterThan(BigInteger, BigInteger)

傳回值,這個值表示 BigInteger 值是否大於另一個 BigInteger 值。Returns a value that indicates whether a BigInteger value is greater than another BigInteger value.

GreaterThanOrEqual(Int64, BigInteger) GreaterThanOrEqual(Int64, BigInteger) GreaterThanOrEqual(Int64, BigInteger) GreaterThanOrEqual(Int64, BigInteger)

傳回值,這個值表示 64 位元帶正負號的整數是否大於或等於 BigInteger 值。Returns a value that indicates whether a 64-bit signed integer is greater than or equal to a BigInteger value.

GreaterThanOrEqual(BigInteger, Int64) GreaterThanOrEqual(BigInteger, Int64) GreaterThanOrEqual(BigInteger, Int64) GreaterThanOrEqual(BigInteger, Int64)

傳回值,這個值表示 BigInteger 值是否大於或等於 64 位元帶正負號的整數值。Returns a value that indicates whether a BigInteger value is greater than or equal to a 64-bit signed integer value.

GreaterThanOrEqual(BigInteger, BigInteger) GreaterThanOrEqual(BigInteger, BigInteger) GreaterThanOrEqual(BigInteger, BigInteger) GreaterThanOrEqual(BigInteger, BigInteger)

傳回值,這個值表示 BigInteger 值是否大於或等於另一個 BigInteger 值。Returns a value that indicates whether a BigInteger value is greater than or equal to another BigInteger value.

GreaterThanOrEqual(BigInteger, UInt64) GreaterThanOrEqual(BigInteger, UInt64) GreaterThanOrEqual(BigInteger, UInt64) GreaterThanOrEqual(BigInteger, UInt64)

傳回值,這個值表示 BigInteger 值是否大於或等於 64 位元不帶正負號的整數值。Returns a value that indicates whether a BigInteger value is greater than or equal to a 64-bit unsigned integer value.

GreaterThanOrEqual(UInt64, BigInteger) GreaterThanOrEqual(UInt64, BigInteger) GreaterThanOrEqual(UInt64, BigInteger) GreaterThanOrEqual(UInt64, BigInteger)

傳回值,這個值表示 64 位元不帶正負號的整數是否大於或等於 BigInteger 值。Returns a value that indicates whether a 64-bit unsigned integer is greater than or equal to a BigInteger value.

Implicit(UInt32 to BigInteger) Implicit(UInt32 to BigInteger) Implicit(UInt32 to BigInteger) Implicit(UInt32 to BigInteger)

定義從 32 位元不帶正負號的整數到 BigInteger 值的隱含轉換。Defines an implicit conversion of a 32-bit unsigned integer to a BigInteger value.

此應用程式開發介面不符合 CLS 標準。This API is not CLS-compliant. 符合規範的替代項目為 Implicit(Int64 to BigInteger)The compliant alternative is Implicit(Int64 to BigInteger).

Implicit(UInt16 to BigInteger) Implicit(UInt16 to BigInteger) Implicit(UInt16 to BigInteger) Implicit(UInt16 to BigInteger)

定義從 16 位元不帶正負號的整數到 BigInteger 值的隱含轉換。Defines an implicit conversion of a 16-bit unsigned integer to a BigInteger value.

此應用程式開發介面不符合 CLS 標準。This API is not CLS-compliant. 符合規範的替代項目為 Implicit(Int32 to BigInteger)The compliant alternative is Implicit(Int32 to BigInteger).

Implicit(SByte to BigInteger) Implicit(SByte to BigInteger) Implicit(SByte to BigInteger) Implicit(SByte to BigInteger)

定義從 8 位元帶正負號的整數到 BigInteger 值的隱含轉換。Defines an implicit conversion of an 8-bit signed integer to a BigInteger value.

此應用程式開發介面不符合 CLS 標準。This API is not CLS-compliant. 符合規範的替代項目為 BigInteger(Int32)The compliant alternative is BigInteger(Int32).

Implicit(UInt64 to BigInteger) Implicit(UInt64 to BigInteger) Implicit(UInt64 to BigInteger) Implicit(UInt64 to BigInteger)

定義從 64 位元不帶正負號的整數到 BigInteger 值的隱含轉換。Defines an implicit conversion of a 64-bit unsigned integer to a BigInteger value.

此應用程式開發介面不符合 CLS 標準。This API is not CLS-compliant. 符合規範的替代項目為 DoubleThe compliant alternative is Double.

Implicit(Int32 to BigInteger) Implicit(Int32 to BigInteger) Implicit(Int32 to BigInteger) Implicit(Int32 to BigInteger)

定義從帶正負號的 32 位元整數到 BigInteger 值的隱含轉換。Defines an implicit conversion of a signed 32-bit integer to a BigInteger value.

Implicit(Int16 to BigInteger) Implicit(Int16 to BigInteger) Implicit(Int16 to BigInteger) Implicit(Int16 to BigInteger)

定義從帶正負號的 16 位元整數到 BigInteger 值的隱含轉換。Defines an implicit conversion of a signed 16-bit integer to a BigInteger value.

Implicit(Byte to BigInteger) Implicit(Byte to BigInteger) Implicit(Byte to BigInteger) Implicit(Byte to BigInteger)

定義從不帶正負號的位元組到 BigInteger 值的隱含轉換。Defines an implicit conversion of an unsigned byte to a BigInteger value.

Implicit(Int64 to BigInteger) Implicit(Int64 to BigInteger) Implicit(Int64 to BigInteger) Implicit(Int64 to BigInteger)

定義從帶正負號的 64 位元整數到 BigInteger 值的隱含轉換。Defines an implicit conversion of a signed 64-bit integer to a BigInteger value.

Increment(BigInteger) Increment(BigInteger) Increment(BigInteger) Increment(BigInteger)

BigInteger 值遞增 1。Increments a BigInteger value by 1.

Inequality(UInt64, BigInteger) Inequality(UInt64, BigInteger) Inequality(UInt64, BigInteger) Inequality(UInt64, BigInteger)

傳回值,這個值表示 64 位元不帶正負號的整數與 BigInteger 值是否不相等。Returns a value that indicates whether a 64-bit unsigned integer and a BigInteger value are not equal.

Inequality(BigInteger, BigInteger) Inequality(BigInteger, BigInteger) Inequality(BigInteger, BigInteger) Inequality(BigInteger, BigInteger)

傳回值,指出兩個 BigInteger 物件是否有不同的值。Returns a value that indicates whether two BigInteger objects have different values.

Inequality(BigInteger, UInt64) Inequality(BigInteger, UInt64) Inequality(BigInteger, UInt64) Inequality(BigInteger, UInt64)

傳回值,這個值表示 BigInteger 值與 64 位元不帶正負號的整數是否不相等。Returns a value that indicates whether a BigInteger value and a 64-bit unsigned integer are not equal.

Inequality(Int64, BigInteger) Inequality(Int64, BigInteger) Inequality(Int64, BigInteger) Inequality(Int64, BigInteger)

傳回值,這個值表示 64 位元帶正負號的整數與 BigInteger 值是否不相等。Returns a value that indicates whether a 64-bit signed integer and a BigInteger value are not equal.

Inequality(BigInteger, Int64) Inequality(BigInteger, Int64) Inequality(BigInteger, Int64) Inequality(BigInteger, Int64)

傳回值,這個值表示 BigInteger 值與 64 位元帶正負號的整數是否不相等。Returns a value that indicates whether a BigInteger value and a 64-bit signed integer are not equal.

LeftShift(BigInteger, Int32) LeftShift(BigInteger, Int32) LeftShift(BigInteger, Int32) LeftShift(BigInteger, Int32)

BigInteger 值向左移動指定的位元數。Shifts a BigInteger value a specified number of bits to the left.

LessThan(Int64, BigInteger) LessThan(Int64, BigInteger) LessThan(Int64, BigInteger) LessThan(Int64, BigInteger)

傳回值,這個值表示 64 位元帶正負號的整數是否小於 BigInteger 值。Returns a value that indicates whether a 64-bit signed integer is less than a BigInteger value.

LessThan(BigInteger, Int64) LessThan(BigInteger, Int64) LessThan(BigInteger, Int64) LessThan(BigInteger, Int64)

傳回值,這個值表示 BigInteger 值是否小於 64 位元帶正負號的整數。Returns a value that indicates whether a BigInteger value is less than a 64-bit signed integer.

LessThan(BigInteger, BigInteger) LessThan(BigInteger, BigInteger) LessThan(BigInteger, BigInteger) LessThan(BigInteger, BigInteger)

傳回值,這個值表示 BigInteger 值是否小於另一個 BigInteger 值。Returns a value that indicates whether a BigInteger value is less than another BigInteger value.

LessThan(BigInteger, UInt64) LessThan(BigInteger, UInt64) LessThan(BigInteger, UInt64) LessThan(BigInteger, UInt64)

傳回值,這個值表示 BigInteger 值是否小於 64 位元不帶正負號的整數。Returns a value that indicates whether a BigInteger value is less than a 64-bit unsigned integer.

LessThan(UInt64, BigInteger) LessThan(UInt64, BigInteger) LessThan(UInt64, BigInteger) LessThan(UInt64, BigInteger)

傳回值,這個值表示 64 位元不帶正負號的整數是否小於 BigInteger 值。Returns a value that indicates whether a 64-bit unsigned integer is less than a BigInteger value.

LessThanOrEqual(UInt64, BigInteger) LessThanOrEqual(UInt64, BigInteger) LessThanOrEqual(UInt64, BigInteger) LessThanOrEqual(UInt64, BigInteger)

傳回值,這個值表示 64 位元不帶正負號的整數是否小於或等於 BigInteger 值。Returns a value that indicates whether a 64-bit unsigned integer is less than or equal to a BigInteger value.

LessThanOrEqual(BigInteger, BigInteger) LessThanOrEqual(BigInteger, BigInteger) LessThanOrEqual(BigInteger, BigInteger) LessThanOrEqual(BigInteger, BigInteger)

傳回值,這個值表示 BigInteger 值是否小於或等於另一個 BigInteger 值。Returns a value that indicates whether a BigInteger value is less than or equal to another BigInteger value.

LessThanOrEqual(BigInteger, UInt64) LessThanOrEqual(BigInteger, UInt64) LessThanOrEqual(BigInteger, UInt64) LessThanOrEqual(BigInteger, UInt64)

傳回值,這個值表示 BigInteger 值是否小於或等於 64 位元不帶正負號的整數。Returns a value that indicates whether a BigInteger value is less than or equal to a 64-bit unsigned integer.

LessThanOrEqual(Int64, BigInteger) LessThanOrEqual(Int64, BigInteger) LessThanOrEqual(Int64, BigInteger) LessThanOrEqual(Int64, BigInteger)

傳回值,這個值表示 64 位元帶正負號的整數是否小於或等於 BigInteger 值。Returns a value that indicates whether a 64-bit signed integer is less than or equal to a BigInteger value.

LessThanOrEqual(BigInteger, Int64) LessThanOrEqual(BigInteger, Int64) LessThanOrEqual(BigInteger, Int64) LessThanOrEqual(BigInteger, Int64)

傳回值,這個值表示 BigInteger 值是否小於或等於 64 位元帶正負號的整數。Returns a value that indicates whether a BigInteger value is less than or equal to a 64-bit signed integer.

Modulus(BigInteger, BigInteger) Modulus(BigInteger, BigInteger) Modulus(BigInteger, BigInteger) Modulus(BigInteger, BigInteger)

傳回從兩個指定的 BigInteger 值相除所得的餘數。Returns the remainder that results from division with two specified BigInteger values.

Multiply(BigInteger, BigInteger) Multiply(BigInteger, BigInteger) Multiply(BigInteger, BigInteger) Multiply(BigInteger, BigInteger)

將兩個指定的 BigInteger 值相乘。Multiplies two specified BigInteger values.

OnesComplement(BigInteger) OnesComplement(BigInteger) OnesComplement(BigInteger) OnesComplement(BigInteger)

傳回 BigInteger 值的位元一進位補數。Returns the bitwise one's complement of a BigInteger value.

RightShift(BigInteger, Int32) RightShift(BigInteger, Int32) RightShift(BigInteger, Int32) RightShift(BigInteger, Int32)

BigInteger 值向右移動指定的位元數。Shifts a BigInteger value a specified number of bits to the right.

Subtraction(BigInteger, BigInteger) Subtraction(BigInteger, BigInteger) Subtraction(BigInteger, BigInteger) Subtraction(BigInteger, BigInteger)

將某個 BigInteger 值減去另一個 BigInteger 值。Subtracts a BigInteger value from another BigInteger value.

UnaryNegation(BigInteger) UnaryNegation(BigInteger) UnaryNegation(BigInteger) UnaryNegation(BigInteger)

將指定的 BigInteger 值變換正負號。Negates a specified BigInteger value.

UnaryPlus(BigInteger) UnaryPlus(BigInteger) UnaryPlus(BigInteger) UnaryPlus(BigInteger)

傳回 BigInteger 運算元的值。Returns the value of the BigInteger operand. (運算元的正負號不會變更)。(The sign of the operand is unchanged.)

明確介面實作

IComparable.CompareTo(Object) IComparable.CompareTo(Object) IComparable.CompareTo(Object) IComparable.CompareTo(Object)

適用於