# BigInteger 结构

## 定义

``public value class BigInteger : IComparable, IComparable<System::Numerics::BigInteger>, IEquatable<System::Numerics::BigInteger>, IFormattable``
``public struct 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``````
``````[<System.Serializable>]
type BigInteger = struct
interface IFormattable``````
``````Public Structure BigInteger
Implements IComparable, IComparable(Of BigInteger), IEquatable(Of BigInteger), IFormattable``````

BigInteger

## 注解

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) 的、、、、、、 Byte Int16 Int32 Int64 SByte UInt16 UInt32UInt64 类型 (的其他整型成员紧密并行。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 范围由其 `MinValue` 和属性指示 `MaxValue`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 对象Instantiating a BigInteger Object

• 您可以使用 `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 中的 (转换 Double 为，将 Decimal 值转换为 BigIntegerThe 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
``````

• 可以使用 `new` 关键字，并向构造函数提供任意大小的字节数组 BigInteger.BigIntegerYou 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).
``````
• 可以调用 ParseTryParse 方法，将数字的字符串表示形式转换为 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. 下面的示例通过多维数据集并将 UInt64.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
``````

### 可变性和 BigInteger 结构Mutability and the BigInteger Structure

``````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)
``````

.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.

``````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
``````

``````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 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
``````

``````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 是-1000000 或4293967296的小字节序十六进制表示形式。For example, 0xC0 0xBD 0xF0 0xFF is the little-endian hexadecimal representation of either -1,000,000 or 4,293,967,296. 由于此数组中最后一个字节的最高有效位为 on，因此该字节数组的值将由 BigInteger(Byte[]) 构造函数解释为-1000000。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
``````

``````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
``````

``````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.
``````

``````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 结构的新实例。Initializes a new instance of the BigInteger structure using the values in a byte array. 使用 BigInteger 值初始化 Decimal 结构的新实例。Initializes a new instance of the BigInteger structure using a Decimal value. 使用双精度浮点值初始化 BigInteger 结构的新实例。Initializes a new instance of the BigInteger structure using a double-precision floating-point value. 使用 32 位带符号整数值初始化 BigInteger 结构的新实例。Initializes a new instance of the BigInteger structure using a 32-bit signed integer value. 使用 64 位带符号整数值初始化 BigInteger 结构的新实例。Initializes a new instance of the BigInteger structure using a 64-bit signed integer value. 使用字节的只读范围中的值初始化 BigInteger 结构的新实例，并选择性地指示符号编码和字节排序方式顺序。Initializes a new instance of the BigInteger structure using the values in a read-only span of bytes, and optionally indicating the signing encoding and the endianness byte order. 使用单精度浮点值初始化 BigInteger 结构的新实例。Initializes a new instance of the BigInteger structure using a single-precision floating-point value. 使用 32 位无符号整数值初始化 BigInteger 结构的新实例。Initializes a new instance of the BigInteger structure using an unsigned 32-bit integer value. 使用 64 位无符号整数值初始化 BigInteger 结构的新实例。Initializes a new instance of the BigInteger structure with an unsigned 64-bit integer value.

## 属性

 指示当前 BigInteger 对象的值是否是偶数。Indicates whether the value of the current BigInteger object is an even number. 指示当前 BigInteger 对象的值是否是 One。Indicates whether the value of the current BigInteger object is One. 指示当前 BigInteger 对象的值是否是 2 的幂。Indicates whether the value of the current BigInteger object is a power of two. 指示当前 BigInteger 对象的值是否是 Zero。Indicates whether the value of the current BigInteger object is Zero. 获取一个表示数字负一 (-1) 的值。Gets a value that represents the number negative one (-1). 获取一个表示数字一 (1) 的值。Gets a value that represents the number one (1). 获取一个数字，该数字指示当前 BigInteger 对象的符号（负、正或零）。Gets a number that indicates the sign (negative, positive, or zero) of the current BigInteger object. 获取一个表示数字 0（零）的值。Gets a value that represents the number 0 (zero).

## 方法

 获取 BigInteger 对象的绝对值。Gets the absolute value of a BigInteger object. 将两个 BigInteger 值相加，并返回结果。Adds two BigInteger values and returns the result. 比较两个 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. 将此实例与另一个 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. 将此实例与 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. 将此实例与指定对象进行比较，并返回一个整数，该整数指示此实例的值是小于、等于还是大于指定对象的值。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. 将此实例与 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. 用另一个值除 BigInteger 值并返回结果。Divides one BigInteger value by another and returns the result. 用另一个值除一个 BigInteger 值，返回结果，并在输出参数中返回余数。Divides one BigInteger value by another, returns the result, and returns the remainder in an output parameter. 返回一个值，该值指示当前实例与指定的 BigInteger 对象是否具有相同的值。Returns a value that indicates whether the current instance and a specified BigInteger object have the same value. 返回一个值，该值指示当前实例与 64 位带符号整数是否具有相同的值。Returns a value that indicates whether the current instance and a signed 64-bit integer have the same value. 返回一个值，该值指示当前实例与指定的对象是否具有相同的值。Returns a value that indicates whether the current instance and a specified object have the same value. 返回一个值，该值指示当前实例与 64 位无符号整数是否具有相同的值。Returns a value that indicates whether the current instance and an unsigned 64-bit integer have the same value. 获取当前实例的最短两个补码表示形式（不带符号位）所需的位数。Gets the number of bits required for shortest two's complement representation of the current instance without the sign bit. Gets the number of bytes that will be output by ToByteArray(Boolean, Boolean) and TryWriteBytes(Span, Int32, Boolean, Boolean). 返回当前 BigInteger 对象的哈希代码。Returns the hash code for the current BigInteger object. 查找两个 BigInteger 值的最大公约数。Finds the greatest common divisor of two BigInteger values. 返回指定数字的自然对数（底为 `e`）。Returns the natural (base `e`) logarithm of a specified number. 返回指定数字在使用指定底时的对数。Returns the logarithm of a specified number in a specified base. 返回指定数字以 10 为底的对数。Returns the base 10 logarithm of a specified number. 返回两个 BigInteger 值中的较大者。Returns the larger of two BigInteger values. 返回两个 BigInteger 值中的较小者。Returns the smaller of two BigInteger values. 对以某个数为底、以另一个数为指数的幂执行模数除法。Performs modulus division on a number raised to the power of another number. 返回两个 BigInteger 值的乘积。Returns the product of two BigInteger values. 对指定的 BigInteger 值求反。Negates a specified BigInteger value. 以指定的样式将包含在指定的字符只读范围内的数字表示形式转换为其 BigInteger 等效项。Converts the representation of a number, contained in the specified read-only span of characters, in a specified style to its BigInteger equivalent. 将数字的字符串表示形式转换为它的等效 BigInteger 表示形式。Converts the string representation of a number to its BigInteger equivalent. 将指定的区域性特定格式的数字字符串表示形式转换为它的等效 BigInteger。Converts the string representation of a number in a specified culture-specific format to its BigInteger equivalent. 将指定样式的数字的字符串表示形式转换为它的等效 BigInteger。Converts the string representation of a number in a specified style to its BigInteger equivalent. 将指定样式和区域性特定格式的数字的字符串表示形式转换为它的等效 BigInteger。Converts the string representation of a number in a specified style and culture-specific format to its BigInteger equivalent. 求以 BigInteger 值为底、以指定的值为指数的幂。Raises a BigInteger value to the power of a specified value. 对两个 BigInteger 值执行整除并返回余数。Performs integer division on two BigInteger values and returns the remainder. 从另一个值中减去一个 BigInteger 值并返回结果。Subtracts one BigInteger value from another and returns the result. 将 BigInteger 值转换为字节数组。Converts a BigInteger value to a byte array. 使用尽可能少的字节数返回此 BigInteger 的值作为字节数组。Returns the value of this BigInteger as a byte array using the fewest number of bytes possible. 如果值为零，则返回一个字节（其元素为 0x00）的数组。If the value is zero, returns an array of one byte whose element is 0x00. 将当前 BigInteger 对象的数值转换为其等效字符串表示形式。Converts the numeric value of the current BigInteger object to its equivalent string representation. 使用指定的区域性特定格式设置信息将当前 BigInteger 对象的数值转换为它的等效字符串表示形式。Converts the numeric value of the current BigInteger object to its equivalent string representation by using the specified culture-specific formatting information. 使用指定的格式将当前 BigInteger 对象的数值转换为它的等效字符串表示形式。Converts the numeric value of the current BigInteger object to its equivalent string representation by using the specified format. 使用指定的格式和区域性特定格式信息将当前 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. 将此大整数实例格式设置到一个字符范围内。Formats this big integer instance into a span of characters. 尝试将指定的字符只读范围中包含的数字的表示形式转换为其 BigInteger 等效项，并返回一个指示转换是否成功的值。Tries to convert the representation of a number contained in the specified read-only character span, to its BigInteger equivalent, and returns a value that indicates whether the conversion succeeded. 尝试将数字的字符串表示形式转换为它的等效 BigInteger，并返回一个指示转换是否成功的值。Tries to convert the string representation of a number to its BigInteger equivalent, and returns a value that indicates whether the conversion succeeded. 尝试将数字的字符串表示形式转换为它的等效 BigInteger，并返回一个指示转换是否成功的值。Tries to convert the string representation of a number to its BigInteger equivalent, and returns a value that indicates whether the conversion succeeded. 尝试将指定样式和区域性特定格式的数字的字符串表示形式转换为其 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. 使用尽可能少的字节数将此 BigInteger 的值复制为小端二进制补码字节。Copies the value of this BigInteger as little-endian twos-complement bytes, using the fewest number of bytes possible. 如果值为零，则输入其元素为 0x00 的字节。If the value is zero, outputs one byte whose element is 0x00.

## 运算符

 将两个指定的 BigInteger 对象的值相加。Adds the values of two specified BigInteger objects. 对两个 BigInteger 值执行按位 `And` 运算。Performs a bitwise `And` operation on two BigInteger values. 对两个 BigInteger 值执行按位 `Or` 运算。Performs a bitwise `Or` operation on two BigInteger values. 将 BigInteger 值减 1。Decrements a BigInteger value by 1. 通过使用整除，将指定的 BigInteger 值除以另一个指定的 BigInteger 值。Divides a specified BigInteger value by another specified BigInteger value by using integer division. 返回一个值，该值指示两个 BigInteger 对象的值是否相等。Returns a value that indicates whether the values of two BigInteger objects are equal. 返回一个值，该值指示 BigInteger 值与带符号长整数值是否相等。Returns a value that indicates whether a BigInteger value and a signed long integer value are equal. 返回一个值，该值指示 BigInteger 值与无符号长整数值是否相等。Returns a value that indicates whether a BigInteger value and an unsigned long integer value are equal. 返回一个值，该值指示带符号长整数值与 BigInteger 值是否相等。Returns a value that indicates whether a signed long integer value and a BigInteger value are equal. 返回一个值，该值指示无符号长整数值与 BigInteger 值是否相等。Returns a value that indicates whether an unsigned long integer value and a BigInteger value are equal. 对两个 BigInteger 值执行按位异 `Or` (`XOr`) 运算。Performs a bitwise exclusive `Or` (`XOr`) operation on two BigInteger values. 定义从 BigInteger 对象到无符号字节值的显式转换。Defines an explicit conversion of a BigInteger object to an unsigned byte value. 定义从 BigInteger 对象到 Decimal 值的显式转换。Defines an explicit conversion of a BigInteger object to a Decimal value. 定义从 BigInteger 对象到 Double 值的显式转换。Defines an explicit conversion of a BigInteger object to a Double value. 定义从 BigInteger 对象到 16 位带符号整数值的显式转换。Defines an explicit conversion of a BigInteger object to a 16-bit signed integer value. 定义从 BigInteger 对象到 32 位带符号整数值的显式转换。Defines an explicit conversion of a BigInteger object to a 32-bit signed integer value. 定义从 BigInteger 对象到 64 位带符号整数值的显式转换。Defines an explicit conversion of a BigInteger object to a 64-bit signed integer value. 定义从 BigInteger 对象到 8 位带符号值的显式转换。Defines an explicit conversion of a BigInteger object to a signed 8-bit value. 此 API 不兼容 CLS。This API is not CLS-compliant. 符合的替代方法是 Int16。The compliant alternative is Int16. 定义从 BigInteger 对象到单精度浮点值的显式转换。Defines an explicit conversion of a BigInteger object to a single-precision floating-point value. 定义从 BigInteger 对象到 16 位无符号整数值的显式转换。Defines an explicit conversion of a BigInteger object to an unsigned 16-bit integer value. 此 API 不兼容 CLS。This API is not CLS-compliant. 符合的替代方法是 Int32。The compliant alternative is Int32. 定义从 BigInteger 对象到 32 位无符号整数值的显式转换。Defines an explicit conversion of a BigInteger object to an unsigned 32-bit integer value. 此 API 不兼容 CLS。This API is not CLS-compliant. 符合的替代方法是 Int64。The compliant alternative is Int64. 定义从 BigInteger 对象到 64 位无符号整数值的显式转换。Defines an explicit conversion of a BigInteger object to an unsigned 64-bit integer value. 此 API 不兼容 CLS。This API is not CLS-compliant. 符合的替代方法是 Double。The compliant alternative is Double. 定义从 Decimal 对象到 BigInteger 值的显式转换。Defines an explicit conversion of a Decimal object to a BigInteger value. 定义从 Double 值到 BigInteger 值的显式转换。Defines an explicit conversion of a Double value to a BigInteger value. 定义从 Single 值到 BigInteger 值的显式转换。Defines an explicit conversion of a Single value to a BigInteger value. 返回一个值，该值指示 BigInteger 值是否大于另一个 BigInteger 值。Returns a value that indicates whether a BigInteger value is greater than another BigInteger value. 返回一个值，该值指示 BigInteger 是否大于 64 位带符号整数值。Returns a value that indicates whether a BigInteger is greater than a 64-bit signed integer value. 返回一个值，该值指示 BigInteger 值是否大于 64 位无符号整数。Returns a value that indicates whether a BigInteger value is greater than a 64-bit unsigned integer. 返回一个值，该值指示 64 位带符号整数是否大于 BigInteger 值。Returns a value that indicates whether a 64-bit signed integer is greater than a BigInteger value. 返回一个值，该值指示 BigInteger 值是否大于 64 位无符号整数。Returns a value that indicates whether a BigInteger value is greater than a 64-bit unsigned integer. 返回一个值，该值指示 BigInteger 值是否大于等于另一个 BigInteger 值。Returns a value that indicates whether a BigInteger value is greater than or equal to another BigInteger value. 返回一个值，该值指示 BigInteger 值是否大于等于 64 位带符号整数值。Returns a value that indicates whether a BigInteger value is greater than or equal to a 64-bit signed integer value. 返回一个值，该值指示 BigInteger 值是否大于等于 64 位无符号整数值。Returns a value that indicates whether a BigInteger value is greater than or equal to a 64-bit unsigned integer value. 返回一个值，该值指示 64 位带符号整数是否大于等于 BigInteger 值。Returns a value that indicates whether a 64-bit signed integer is greater than or equal to a BigInteger value. 返回一个值，该值指示 64 位无符号整数是否大于等于 BigInteger 值。Returns a value that indicates whether a 64-bit unsigned integer is greater than or equal to a BigInteger value. 定义从无符号字节到 BigInteger 值的隐式转换。Defines an implicit conversion of an unsigned byte to a BigInteger value. 定义从 16 位带符号整数到 BigInteger 值的隐式转换。Defines an implicit conversion of a signed 16-bit integer to a BigInteger value. 定义从 32 位带符号整数到 BigInteger 值的隐式转换。Defines an implicit conversion of a signed 32-bit integer to a BigInteger value. 定义从 64 位带符号整数到 BigInteger 值的隐式转换。Defines an implicit conversion of a signed 64-bit integer to a BigInteger value. 定义从 8 位带符号整数到 BigInteger 值的隐式转换。Defines an implicit conversion of an 8-bit signed integer to a BigInteger value. 此 API 不兼容 CLS。This API is not CLS-compliant. 符合的替代方法是 BigInteger(Int32)。The compliant alternative is BigInteger(Int32). 定义从 16 位无符号整数到 BigInteger 值的隐式转换。Defines an implicit conversion of a 16-bit unsigned integer to a BigInteger value. 此 API 不兼容 CLS。This API is not CLS-compliant. 符合的替代方法是 Implicit(Int32 to BigInteger)。The compliant alternative is Implicit(Int32 to BigInteger). 定义从 32 位无符号整数到 BigInteger 值的隐式转换。Defines an implicit conversion of a 32-bit unsigned integer to a BigInteger value. 此 API 不兼容 CLS。This API is not CLS-compliant. 符合的替代方法是 Implicit(Int64 to BigInteger)。The compliant alternative is Implicit(Int64 to BigInteger). 定义从 64 位无符号整数到 BigInteger 值的隐式转换。Defines an implicit conversion of a 64-bit unsigned integer to a BigInteger value. 此 API 不兼容 CLS。This API is not CLS-compliant. 符合的替代方法是 Double。The compliant alternative is Double. 将 BigInteger 值加 1。Increments a BigInteger value by 1. 返回一个值，该值指示两个 BigInteger 对象是否具有不同的值。Returns a value that indicates whether two BigInteger objects have different values. 返回一个值，该值指示 BigInteger 值与 64 位带符号整数是否不相等。Returns a value that indicates whether a BigInteger value and a 64-bit signed integer are not equal. 返回一个值，该值指示 BigInteger 值与 64 位无符号整数是否不相等。Returns a value that indicates whether a BigInteger value and a 64-bit unsigned integer are not equal. 返回一个值，该值指示 64 位带符号整数与 BigInteger 值是否不相等。Returns a value that indicates whether a 64-bit signed integer and a BigInteger value are not equal. 返回一个值，该值指示 64 位无符号整数与 BigInteger 值是否不相等。Returns a value that indicates whether a 64-bit unsigned integer and a BigInteger value are not equal. 将 BigInteger 值向左移动指定的位数。Shifts a BigInteger value a specified number of bits to the left. 返回一个值，该值指示 BigInteger 值是否小于另一个 BigInteger 值。Returns a value that indicates whether a BigInteger value is less than another BigInteger value. 返回一个值，该值指示 BigInteger 值是否小于 64 位带符号整数。Returns a value that indicates whether a BigInteger value is less than a 64-bit signed integer. 返回一个值，该值指示 BigInteger 值是否小于 64 位无符号整数。Returns a value that indicates whether a BigInteger value is less than a 64-bit unsigned integer. 返回一个值，该值指示 64 位带符号整数是否小于 BigInteger 值。Returns a value that indicates whether a 64-bit signed integer is less than a BigInteger value. 返回一个值，该值指示 64 位无符号整数是否小于 BigInteger 值。Returns a value that indicates whether a 64-bit unsigned integer is less than a BigInteger value. 返回一个值，该值指示 BigInteger 值是否小于等于另一个 BigInteger 值。Returns a value that indicates whether a BigInteger value is less than or equal to another BigInteger value. 返回一个值，该值指示 BigInteger 值是否小于等于 64 位带符号整数。Returns a value that indicates whether a BigInteger value is less than or equal to a 64-bit signed integer. 返回一个值，该值指示 BigInteger 值是否小于等于 64 位无符号整数。Returns a value that indicates whether a BigInteger value is less than or equal to a 64-bit unsigned integer. 返回一个值，该值指示 64 位带符号整数是否小于等于 BigInteger 值。Returns a value that indicates whether a 64-bit signed integer is less than or equal to a BigInteger value. 返回一个值，该值指示 64 位无符号整数是否小于等于 BigInteger 值。Returns a value that indicates whether a 64-bit unsigned integer is less than or equal to a BigInteger value. 返回两个指定 BigInteger 值相除所得的余数。Returns the remainder that results from division with two specified BigInteger values. 两个指定的 BigInteger 值相乘。Multiplies two specified BigInteger values. 返回 BigInteger 值的按位二进制反码。Returns the bitwise one's complement of a BigInteger value. 将 BigInteger 值向右移动指定的位数。Shifts a BigInteger value a specified number of bits to the right. 从另一个 BigInteger 值中减去 BigInteger 值。Subtracts a BigInteger value from another BigInteger value. 对指定的 BigInteger 值求反。Negates a specified BigInteger value. 返回 BigInteger 操作数的值。Returns the value of the BigInteger operand. （操作数的符号不变。）(The sign of the operand is unchanged.)

## 显式接口实现

 将此实例与指定对象进行比较，并返回一个整数，该整数指示此实例的值是小于、等于还是大于指定对象的值。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.