BigInteger BigInteger BigInteger BigInteger Struct

Definición

Representa un entero con signo arbitrariamente grande.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
Herencia
BigIntegerBigIntegerBigIntegerBigInteger
Atributos
Implementaciones

Comentarios

El BigInteger tipo es un tipo inmutable que representa un entero arbitrariamente grande cuyo valor en teoría no tiene ningún límite superior o inferior.The BigInteger type is an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds. Los miembros de la BigInteger tipo análogos a los de otros tipos integrales (el Byte, Int16, Int32, Int64, SByte, UInt16, UInt32, y UInt64 tipos).The members of the BigInteger type closely parallel those of other integral types (the Byte, Int16, Int32, Int64, SByte, UInt16, UInt32, and UInt64 types). Este tipo difiere de otros tipos integrales en el .NET Framework.NET Framework, que tiene un intervalo indicado por su MinValue y MaxValue propiedades.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.

Nota

Dado que el BigInteger tipo es inmutable (consulte mutabilidad y la estructura BigInteger) y porque no tiene ningún límite superior o inferior, una OutOfMemoryException se pueden producir para cualquier operación que hace que un BigInteger valor crezca demasiado grandes.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.

Instancias de un objeto BigIntegerInstantiating a BigInteger Object

Puede crear instancias de un BigInteger objetos de varias maneras:You can instantiate a BigInteger object in several ways:

  • Puede usar el new palabra clave y cualquier valor integral o de punto flotante se proporciona como parámetro a la BigInteger constructor.You can use the new keyword and provide any integral or floating-point value as a parameter to the BigInteger constructor. (Se truncan los valores de punto flotante antes de que se asignan a la BigInteger.) El ejemplo siguiente muestra cómo usar el new palabra clave para crear una instancia BigInteger valores.(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		
    
  • Puede declarar un BigInteger variable y asigne un valor como lo haría con cualquier tipo numérico, siempre y cuando ese valor es un tipo entero.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. El ejemplo siguiente utiliza la asignación para crear un BigInteger valor desde un Int64.The 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
    
  • Puede asignar un valor decimal o de punto flotante a un BigInteger objeto si convierte el valor o conviértalo primero.You can assign a decimal or floating-point value to a BigInteger object if you cast the value or convert it first. El ejemplo siguiente se convierte (en C#) o convierte (en Visual Basic) explícitamente un Double y un Decimal valor a un BigInteger.The 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      
    

Estos métodos le permiten crear una instancia de un BigInteger sólo los tipos de objeto cuyo valor está en el intervalo de uno de los valores numéricos existente.These methods enable you to instantiate a BigInteger object whose value is in the range of one of the existing numeric types only. Puede crear instancias de un BigInteger objeto cuyo valor puede superar el intervalo de los tipos numéricos existentes en una de estas tres maneras:You can instantiate a BigInteger object whose value can exceed the range of the existing numeric types in one of three ways:

  • Puede usar el new palabra clave y proporcionar una matriz de bytes de cualquier tamaño la BigInteger.BigInteger constructor.You can use the new keyword and provide a byte array of any size to the BigInteger.BigInteger constructor. Por ejemplo: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).
    
  • Puede llamar a la Parse o TryParse métodos para convertir la representación de cadena de un número en un BigInteger.You can call the Parse or TryParse methods to convert the string representation of a number to a BigInteger. Por ejemplo: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
    
  • Puede llamar a un static (Shared en Visual Basic) BigInteger método que realiza alguna operación en una expresión numérica y devuelve un calculado BigInteger resultado.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. En el siguiente ejemplo para ello, elevando UInt64.MaxValue y asignar el resultado a un BigInteger.The 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
    

El valor inicializado de un BigInteger es Zero.The uninitialized value of a BigInteger is Zero.

Realizar operaciones en valores BigIntegerPerforming Operations on BigInteger Values

Puede usar un BigInteger como utilizaría cualquier otro tipo integral de la instancia.You can use a BigInteger instance as you would use any other integral type. BigInteger sobrecarga los operadores numéricos estándar para permitirle realizar operaciones matemáticas básicas como suma, resta, división, multiplicación, resta, negación y negación unaria.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. También puede usar los operadores numéricos estándar para comparar dos BigInteger valores entre sí.You can also use the standard numeric operators to compare two BigInteger values with each other. Al igual que otros tipos integrales, BigInteger también es compatible con el bit a bit And, Or, XOr, deja la tecla MAYÚS y operadores de desplazamiento a la derecha.Like the other integral types, BigInteger also supports the bitwise And, Or, XOr, left shift, and right shift operators. Para los idiomas que no admiten operadores personalizados, la BigInteger estructura también proporciona los métodos equivalentes para realizar operaciones matemáticas.For languages that do not support custom operators, the BigInteger structure also provides equivalent methods for performing mathematical operations. Estos incluyen Add, Divide, Multiply, Negate, Subtractentre otras.These include Add, Divide, Multiply, Negate, Subtract, and several others.

Muchos de los miembros de la BigInteger estructura corresponden directamente a los miembros de otros tipos integrales.Many members of the BigInteger structure correspond directly to members of the other integral types. Además, BigInteger agrega miembros, como lo siguiente:In addition, BigInteger adds members such as the following:

Muchos de estos miembros adicionales corresponden a los miembros de la Math (clase), que proporciona la funcionalidad para trabajar con los tipos numéricos primitivos.Many of these additional members correspond to the members of the Math class, which provides the functionality to work with the primitive numeric types.

Mutabilidad y BigInteger (estructura)Mutability and the BigInteger Structure

El ejemplo siguiente crea un BigInteger de objetos y, a continuación, aumenta su valor en uno.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)

Aunque este ejemplo aparece modificar el valor del objeto existente, no es el caso.Although this example appears to modify the value of the existing object, this is not the case. BigInteger los objetos son inmutables, lo que significa que internamente, common language runtime realmente crea una nueva BigInteger objeto y le asigna un valor de una unidad mayor que su valor anterior.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. Este nuevo objeto, a continuación, se devuelve al llamador.This new object is then returned to the caller.

Nota

Los demás tipos numéricos en .NET Framework también son inmutables.The other numeric types in the .NET Framework are also immutable. Sin embargo, dado que el BigInteger tipo no tiene ningún límite superior o inferior, sus valores pueden llegar a ser muy grandes y tiene un impacto cuantificable sobre el rendimiento.However, because the BigInteger type has no upper or lower bounds, its values can grow extremely large and have a measurable impact on performance.

Aunque este proceso es transparente para el llamador, disminuye el rendimiento.Although this process is transparent to the caller, it does incur a performance penalty. En algunos casos, especialmente cuando las operaciones repetidas se realizan en un bucle en gran BigInteger valores, esa disminución del rendimiento puede ser considerable.In some cases, especially when repeated operations are performed in a loop on very large BigInteger values, that performance penalty can be significant. Por ejemplo, en el ejemplo siguiente, se realiza una operación repetidamente hasta un millón de veces y un BigInteger valor se incrementa en uno cada vez que la operación se realiza correctamente.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

En tal caso, puede mejorar el rendimiento mediante la realización de todos los trabajos intermedios en un Int32 variable.In such a case, you can improve performance by performing all intermediate assignments to an Int32 variable. El valor final de la variable, a continuación, puede asignarse a la BigInteger objeto cuando se sale del bucle.The final value of the variable can then be assigned to the BigInteger object when the loop exits. Esto se muestra en el ejemplo siguiente.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

Trabajar con matrices de bytes y cadenas hexadecimalesWorking with Byte Arrays and Hexadecimal Strings

Si convierte BigInteger valores a las matrices de bytes, o si convierte las matrices de bytes a BigInteger valores, debe tener en cuenta el orden de bytes.If you convert BigInteger values to byte arrays, or if you convert byte arrays to BigInteger values, you must consider the order of bytes. El BigInteger estructura espera los bytes individuales en una matriz de bytes que aparezcan en orden little-endian (es decir, los bytes de orden inferior del valor preceden a los bytes de orden superior).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). Puede ida y vuelta una BigInteger valor mediante una llamada a la ToByteArray método y, a continuación, pasa el byte resultante de matriz a la BigInteger(Byte[]) constructor, como se muestra en el ejemplo siguiente.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

Para crear instancias de un BigInteger valor desde una matriz de bytes que representa un valor de algún otro tipo entero, puede pasar el valor entero para la BitConverter.GetBytes método y, a continuación, pasa el byte resultante de matriz a la BigInteger(Byte[]) constructor.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. El ejemplo siguiente crea un BigInteger valor desde una matriz de bytes que representa un Int16 valor.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

El BigInteger estructura se da por supuesto que los valores negativos se almacenan utilizando dos representación del complemento.The BigInteger structure assumes that negative values are stored by using two's complement representation. Dado que el BigInteger estructura representa un valor numérico sin longitud fija, el BigInteger(Byte[]) constructor siempre interpreta el bit más significativo del último byte de la matriz como un bit de signo.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. Para evitar la BigInteger(Byte[]) valores de constructor de confundir las dos representación del complemento de un valor negativo con la representación de signo y magnitud de un valor positivo, positivo en el que el máximo bit significativo del último byte de la matriz de bytes Normalmente, sería conjunto debe incluir un byte adicional cuyo valor es 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. Por ejemplo, 0xC0 0xBD 0xF0 0xFF es la representación hexadecimal de little-endian de -1.000.000 o 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. Dado que es el bit más significativo del último byte de la matriz en, el valor de la matriz de bytes se interpretaría por la BigInteger(Byte[]) constructor como -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. Para crear instancias de un BigInteger cuyo valor es positivo, una matriz de bytes cuyos elementos son 0xC0 0xBD 0xF0 0xFF 0x00 deben pasarse al constructor.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. Esto se ilustra en el siguiente ejemplo: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      

Las matrices de bytes creadas por el ToByteArray método desde los valores positivos incluyen este byte de valor cero adicional.Byte arrays created by the ToByteArray method from positive values include this extra zero-value byte. Por lo tanto, el BigInteger estructura puede valores de ida y vuelta correctamente mediante la asignación a y, a continuación, restaurarlos desde matrices de bytes, como se muestra en el ejemplo siguiente.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

Sin embargo, quizás deba agregar este byte del valor cero adicional a las matrices de bytes que se crean dinámicamente por el desarrollador o que son devueltas por los métodos que convierten los enteros sin signo en matrices de bytes (como BitConverter.GetBytes(UInt16), BitConverter.GetBytes(UInt32), y 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)).

Al analizar una cadena hexadecimal y la BigInteger.Parse(String, NumberStyles) y BigInteger.Parse(String, NumberStyles, IFormatProvider) métodos suponen que si se establece el bit más significativo del primer byte de la cadena, o si el primer dígito hexadecimal de la cadena representa los cuatro bits inferiores de un valor de byte, el valor es se representan mediante dos representación del complemento.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. Por ejemplo, "FF01" y "F01" representan el valor decimal -255.For example, both "FF01" and "F01" represent the decimal value -255. Para diferenciar positivo de los valores negativos, los valores positivos deben incluir un cero inicial.To differentiate positive from negative values, positive values should include a leading zero. Las sobrecargas pertinentes de la ToString método, cuando se pasan la cadena de formato "X", agregue un cero inicial a la cadena hexadecimal devuelta para los valores positivos.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. Esto hace posible de ida y vuelta BigInteger valores usando el ToString y Parse métodos, como se muestra en el ejemplo siguiente.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.

Sin embargo, las cadenas hexadecimales se crean mediante una llamada a la ToString métodos de los otros tipos enteros o de las sobrecargas de los ToString método que incluyen un toBase parámetro no indican el signo del valor o el tipo de datos de origen desde el que se derivó la cadena hexadecimal.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. Crear instancias de correctamente un BigInteger valor de este tipo de cadena requiere alguna lógica adicional.Successfully instantiating a BigInteger value from such a string requires some additional logic. El ejemplo siguiente proporciona una implementación posible.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.

Constructores

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

Inicializa una nueva instancia de la estructura BigInteger utilizando los valores de una matriz de bytes.Initializes a new instance of the BigInteger structure using the values in a byte array.

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

Inicializa una nueva instancia de la estructura BigInteger utilizando un valor Decimal.Initializes a new instance of the BigInteger structure using a Decimal value.

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

Inicializa una nueva instancia de la estructura BigInteger utilizando un valor de punto flotante de precisión doble.Initializes a new instance of the BigInteger structure using a double-precision floating-point value.

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

Inicializa una nueva instancia de la estructura BigInteger usando un valor entero de 32 bits con signo.Initializes a new instance of the BigInteger structure using a 32-bit signed integer value.

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

Inicializa una nueva instancia de la estructura BigInteger usando un valor entero de 64 bits con signo.Initializes a new instance of the BigInteger structure using a 64-bit signed integer value.

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

Inicializa una nueva instancia de la estructura BigInteger utilizando un valor de punto flotante de precisión sencilla.Initializes a new instance of the BigInteger structure using a single-precision floating-point value.

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

Inicializa una nueva instancia de la estructura BigInteger utilizando un valor entero de 32 bits sin signo.Initializes a new instance of the BigInteger structure using an unsigned 32-bit integer value.

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

Inicializa una nueva instancia de la estructura BigInteger con un valor entero de 64 bits sin signo.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)

Propiedades

IsEven IsEven IsEven IsEven

Indica si el valor del objeto BigInteger actual es un número par.Indicates whether the value of the current BigInteger object is an even number.

IsOne IsOne IsOne IsOne

Indica si el valor del objeto BigInteger actual es One.Indicates whether the value of the current BigInteger object is One.

IsPowerOfTwo IsPowerOfTwo IsPowerOfTwo IsPowerOfTwo

Indica si el valor del objeto BigInteger actual es una potencia de dos.Indicates whether the value of the current BigInteger object is a power of two.

IsZero IsZero IsZero IsZero

Indica si el valor del objeto BigInteger actual es Zero.Indicates whether the value of the current BigInteger object is Zero.

MinusOne MinusOne MinusOne MinusOne

Obtiene un valor que representa menos uno (-1).Gets a value that represents the number negative one (-1).

One One One One

Obtiene un valor que representa el número uno (1).Gets a value that represents the number one (1).

Sign Sign Sign Sign

Obtiene un número que indica el signo (negativo, positivo o cero) del objeto BigInteger actual.Gets a number that indicates the sign (negative, positive, or zero) of the current BigInteger object.

Zero Zero Zero Zero

Obtiene un valor que representa el número 0 (cero).Gets a value that represents the number 0 (zero).

Métodos

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

Obtiene el valor absoluto de un objeto BigInteger.Gets the absolute value of a BigInteger object.

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

Suma dos valores BigInteger y devuelve el resultado.Adds two BigInteger values and returns the result.

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

Compara dos valores BigInteger y devuelve un entero que indica si el primer valor es menor, igual o mayor que el segundo.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)

Compara esta instancia con un objeto especificado y devuelve un entero que indica si el valor de esta instancia es mayor, igual o menor que el valor del objeto especificado.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)

Compara esta instancia con un entero de 64 bits sin signo y devuelve un entero que indica si el valor de esta instancia es menor, igual o mayor que el valor del entero de 64 bits sin signo.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)

Compara esta instancia con un entero de 64 bits con signo y devuelve un entero que indica si el valor de esta instancia es menor, igual o mayor que el valor del entero de 64 bits con signo.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)

Compara esta instancia con un segundo BigInteger y devuelve un entero que indica si el valor de esta instancia es menor, igual o mayor que el valor del objeto especificado.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)

Divide un valor BigInteger por otro y devuelve el resultado.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)

Divide un valor BigInteger por otro, devuelve el resultado y devuelve el resto en un parámetro de salida.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)

Devuelve un valor que indica si la instancia actual y un entero de 64 bits con signo tienen el mismo valor.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)

Devuelve un valor que indica si la instancia actual y un objeto BigInteger especificado tienen el mismo valor.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)

Devuelve un valor que indica si la instancia actual y un objeto especificado tienen el mismo valor.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)

Devuelve un valor que indica si la instancia actual y un entero de 64 bits sin signo tienen el mismo valor.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()

Devuelve el código hash del objeto BigInteger actual.Returns the hash code for the current BigInteger object.

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

Busca el máximo común divisor de dos valores BigInteger.Finds the greatest common divisor of two BigInteger values.

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

Devuelve el logaritmo natural (en base e) de un número especificado.Returns the natural (base e) logarithm of a specified number.

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

Devuelve el logaritmo de un número especificado en una base determinada.Returns the logarithm of a specified number in a specified base.

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

Devuelve el logaritmo en base 10 de un número especificado.Returns the base 10 logarithm of a specified number.

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

Devuelve el mayor de dos valores BigInteger.Returns the larger of two BigInteger values.

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

Devuelve el menor de dos valores BigInteger.Returns the smaller of two BigInteger values.

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

Realiza una división de módulo en un número elevado a la potencia de otro número.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)

Devuelve el producto de dos valores BigInteger.Returns the product of two BigInteger values.

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

Crea el negativo de un valor BigInteger especificado.Negates a specified BigInteger value.

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

Convierte la representación en forma de cadena de un número en su BigInteger equivalente.Converts the string representation of a number to its BigInteger equivalent.

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

Convierte la representación de cadena de un número con un estilo especificado en su BigInteger equivalente.Converts 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)

Convierte la representación en forma de cadena de un número con el formato específico de la referencia cultural indicada en su BigInteger equivalente.Converts 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)

Convierte la representación de cadena de un número con el estilo y el formato específico de la referencia cultural que se hayan especificado en su equivalente de BigInteger.Converts 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)

Eleva un valor BigInteger a la potencia del valor especificado.Raises a BigInteger value to the power of a specified value.

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

Realiza la división entera en dos valores BigInteger y devuelve el resto.Performs integer division on two BigInteger values and returns the remainder.

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

Resta un valor BigInteger de otro y devuelve el resultado.Subtracts one BigInteger value from another and returns the result.

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

Convierte un valor BigInteger en una matriz de bytes.Converts a BigInteger value to a byte array.

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

Convierte el valor numérico del objeto BigInteger actual en su representación de cadena equivalente.Converts the numeric value of the current BigInteger object to its equivalent string representation.

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

Convierte el valor numérico del objeto BigInteger actual en su representación de cadena equivalente usando la información de formato específica de la referencia cultural indicada.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)

Convierte el valor numérico del objeto BigInteger actual en su representación de cadena equivalente con el formato especificado.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)

Convierte el valor numérico del objeto BigInteger actual en su representación de cadena equivalente usando el formato especificado y la información de formato específica de la referencia cultural.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)

Intenta convertir la representación en forma de cadena de un número en su equivalente BigInteger y devuelve un valor que indica si la conversión tuvo éxito.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)

Intenta convertir la representación de cadena de un número con un estilo específico y un formato específico de la referencia cultural en su equivalente de BigInteger y devuelve un valor que indica si la conversión fue correcta.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)

Operadores

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

Suma los valores de dos objetos BigInteger especificados.Adds the values of two specified BigInteger objects.

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

Realiza una operación And bit a bit en dos valores BigInteger.Performs a bitwise And operation on two BigInteger values.

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

Realiza una operación Or bit a bit en dos valores BigInteger.Performs a bitwise Or operation on two BigInteger values.

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

Disminuye un valor BigInteger en 1.Decrements a BigInteger value by 1.

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

Divide un valor BigInteger especificado por otro valor BigInteger indicado utilizando división de enteros.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)

Devuelve un valor que indica si un valor entero long con signo y un valor BigInteger son iguales.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)

Devuelve un valor que indica si un valor BigInteger y un valor entero long con signo son iguales.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)

Devuelve un valor que indica si los valores de dos objetos BigInteger son iguales.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)

Devuelve un valor que indica si un valor BigInteger y un valor entero long sin signo son iguales.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)

Devuelve un valor que indica si un valor entero long sin signo y un valor BigInteger son iguales.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)

Realiza una operación exclusiva Or (XOr) bit a bit en dos valores BigInteger.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)

Define una conversión explícita de un objeto Decimal en un valor 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)

Define una conversión explícita de un valor Double en un valor 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)

Define una conversión explícita de un objeto BigInteger en un valor de byte sin signo.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)

Define una conversión explícita de un objeto BigInteger en un valor 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)

Define una conversión explícita de un objeto BigInteger en un valor 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)

Define una conversión explícita de un objeto BigInteger en un valor entero de 16 bits con signo.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)

Define una conversión explícita de un objeto BigInteger en un valor entero de 32 bits con signo.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)

Define una conversión explícita de un objeto BigInteger en un valor entero de 64 bits con signo.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)

Define una conversión explícita de un objeto BigInteger en un valor de 8 bits con signo.Defines an explicit conversion of a BigInteger object to a signed 8-bit value.

Esta API no es conforme a CLS.This API is not CLS-compliant. La alternativa conforme es Int16.The compliant alternative is Int16.

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

Define una conversión explícita de un objeto BigInteger en un valor de punto flotante de precisión sencilla.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)

Define una conversión explícita de un objeto BigInteger en un valor entero de 16 bits sin signo.Defines an explicit conversion of a BigInteger object to an unsigned 16-bit integer value.

Esta API no es conforme a CLS.This API is not CLS-compliant. La alternativa conforme es Int32.The compliant alternative is Int32.

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

Define una conversión explícita de un objeto BigInteger en un valor entero de 32 bits sin signo.Defines an explicit conversion of a BigInteger object to an unsigned 32-bit integer value.

Esta API no es conforme a CLS.This API is not CLS-compliant. La alternativa conforme es Int64.The compliant alternative is Int64.

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

Define una conversión explícita de un objeto BigInteger en un valor entero de 64 bits sin signo.Defines an explicit conversion of a BigInteger object to an unsigned 64-bit integer value.

Esta API no es conforme a CLS.This API is not CLS-compliant. La alternativa conforme es Double.The compliant alternative is Double.

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

Define una conversión explícita de un valor Single en un valor 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)

Devuelve un valor que indica si un valor BigInteger es mayor que un entero de 64 bits sin signo.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)

Devuelve un valor que indica si un valor BigInteger es mayor que un entero de 64 bits sin signo.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)

Devuelve un valor que indica si un entero de 64 bits con signo es mayor que un valor 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)

Devuelve un valor que indica si un valor BigInteger es mayor que un valor entero de 64 bits con signo.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)

Devuelve un valor que indica si un valor BigInteger es mayor que otro valor 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)

Devuelve un valor que indica si un entero de 64 bits con signo es mayor o igual que un valor 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)

Devuelve un valor que indica si un valor BigInteger es mayor o igual que un valor entero de 64 bits con signo.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)

Devuelve un valor que indica si un valor BigInteger es mayor o igual que otro valor 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)

Devuelve un valor que indica si un valor BigInteger es mayor o igual que un valor entero de 64 bits sin signo.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)

Devuelve un valor que indica si un entero de 64 bits sin signo es mayor o igual que un valor 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)

Define una conversión implícita de un entero de 32 bits sin signo en un valor BigInteger.Defines an implicit conversion of a 32-bit unsigned integer to a BigInteger value.

Esta API no es conforme a CLS.This API is not CLS-compliant. La alternativa conforme es 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)

Define una conversión implícita de un entero de 16 bits sin signo en un valor BigInteger.Defines an implicit conversion of a 16-bit unsigned integer to a BigInteger value.

Esta API no es conforme a CLS.This API is not CLS-compliant. La alternativa conforme es 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)

Define una conversión implícita de un entero de 8 bits con signo en un valor BigInteger.Defines an implicit conversion of an 8-bit signed integer to a BigInteger value.

Esta API no es conforme a CLS.This API is not CLS-compliant. La alternativa conforme es BigInteger(Int32).The compliant alternative is BigInteger(Int32).

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

Define una conversión implícita de un entero de 64 bits sin signo en un valor BigInteger.Defines an implicit conversion of a 64-bit unsigned integer to a BigInteger value.

Esta API no es conforme a CLS.This API is not CLS-compliant. La alternativa conforme es Double.The compliant alternative is Double.

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

Define una conversión implícita de un entero de 32 bits con signo en un valor 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)

Define una conversión implícita de un entero de 16 bits con signo en un valor 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)

Define una conversión implícita de un byte sin signo en un valor 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)

Define una conversión implícita de un entero de 64 bits con signo en un valor BigInteger.Defines an implicit conversion of a signed 64-bit integer to a BigInteger value.

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

Aumenta un valor BigInteger en 1.Increments a BigInteger value by 1.

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

Devuelve un valor que indica si un entero de 64 bits sin signo y un valor BigInteger no son iguales.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)

Devuelve un valor que indica si dos objetos BigInteger tienen valores diferentes.Returns a value that indicates whether two BigInteger objects have different values.

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

Devuelve un valor que indica si un valor BigInteger y un valor de 64 bits sin signo no son iguales.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)

Devuelve un valor que indica si un entero de 64 bits con signo y un valor BigInteger no son iguales.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)

Devuelve un valor que indica si un valor BigInteger y un valor de 64 bits con signo no son iguales.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)

Desplaza un valor BigInteger un número especificado de bits a la izquierda.Shifts a BigInteger value a specified number of bits to the left.

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

Devuelve un valor que indica si un entero de 64 bits con signo es menor que un valor 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)

Devuelve un valor que indica si un valor BigInteger es menor que un entero de 64 bits con signo.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)

Devuelve un valor que indica si un valor BigInteger es menor que otro valor 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)

Devuelve un valor que indica si un valor BigInteger es menor que un entero de 64 bits sin signo.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)

Devuelve un valor que indica si un entero de 64 bits sin signo es menor que un valor 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)

Devuelve un valor que indica si un entero de 64 bits sin signo es menor o igual que un valor 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)

Devuelve un valor que indica si un valor BigInteger es menor o igual que otro valor 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)

Devuelve un valor que indica si un valor BigInteger es menor o igual que un entero de 64 bits sin signo.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)

Devuelve un valor que indica si un entero de 64 bits con signo es menor o igual que un valor 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)

Devuelve un valor que indica si un valor BigInteger es menor o igual que un entero de 64 bits con signo.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)

Devuelve el resto que se obtiene al dividir dos valores BigInteger especificados.Returns the remainder that results from division with two specified BigInteger values.

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

Multiplica dos valores BigInteger especificados.Multiplies two specified BigInteger values.

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

Devuelve el complemento de uno bit a bit de un valor BigInteger.Returns the bitwise one's complement of a BigInteger value.

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

Desplaza un valor BigInteger un número especificado de bits a la derecha.Shifts a BigInteger value a specified number of bits to the right.

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

Resta un valor BigInteger de otro valor BigInteger.Subtracts a BigInteger value from another BigInteger value.

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

Crea el negativo de un valor BigInteger especificado.Negates a specified BigInteger value.

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

Devuelve el valor del operando BigInteger.Returns the value of the BigInteger operand. (El signo del operando no cambia).(The sign of the operand is unchanged.)

Implementaciones de interfaz explícitas

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

Se aplica a