BigInteger 構造体

定義

任意の大きい符号付き整数を表します。

public value class BigInteger : IComparable, IComparable<System::Numerics::BigInteger>, IEquatable<System::Numerics::BigInteger>, IFormattable
public value class BigInteger : IComparable<System::Numerics::BigInteger>, IEquatable<System::Numerics::BigInteger>, IParsable<System::Numerics::BigInteger>, ISpanParsable<System::Numerics::BigInteger>, IUtf8SpanParsable<System::Numerics::BigInteger>, System::Numerics::IAdditionOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IAdditiveIdentity<System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IBinaryInteger<System::Numerics::BigInteger>, System::Numerics::IBinaryNumber<System::Numerics::BigInteger>, System::Numerics::IBitwiseOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IComparisonOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, bool>, System::Numerics::IDecrementOperators<System::Numerics::BigInteger>, System::Numerics::IDivisionOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IEqualityOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, bool>, System::Numerics::IIncrementOperators<System::Numerics::BigInteger>, System::Numerics::IModulusOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IMultiplicativeIdentity<System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IMultiplyOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::INumber<System::Numerics::BigInteger>, System::Numerics::INumberBase<System::Numerics::BigInteger>, System::Numerics::IShiftOperators<System::Numerics::BigInteger, int, System::Numerics::BigInteger>, System::Numerics::ISignedNumber<System::Numerics::BigInteger>, System::Numerics::ISubtractionOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IUnaryNegationOperators<System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IUnaryPlusOperators<System::Numerics::BigInteger, System::Numerics::BigInteger>
public value class BigInteger : IComparable, IComparable<System::Numerics::BigInteger>, IEquatable<System::Numerics::BigInteger>, ISpanFormattable
public value class BigInteger : IComparable<System::Numerics::BigInteger>, IEquatable<System::Numerics::BigInteger>, IParsable<System::Numerics::BigInteger>, ISpanParsable<System::Numerics::BigInteger>, System::Numerics::IAdditionOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IAdditiveIdentity<System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IBinaryInteger<System::Numerics::BigInteger>, System::Numerics::IBinaryNumber<System::Numerics::BigInteger>, System::Numerics::IBitwiseOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IComparisonOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, bool>, System::Numerics::IDecrementOperators<System::Numerics::BigInteger>, System::Numerics::IDivisionOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IEqualityOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, bool>, System::Numerics::IIncrementOperators<System::Numerics::BigInteger>, System::Numerics::IModulusOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IMultiplicativeIdentity<System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IMultiplyOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::INumber<System::Numerics::BigInteger>, System::Numerics::INumberBase<System::Numerics::BigInteger>, System::Numerics::IShiftOperators<System::Numerics::BigInteger, int, System::Numerics::BigInteger>, System::Numerics::ISignedNumber<System::Numerics::BigInteger>, System::Numerics::ISubtractionOperators<System::Numerics::BigInteger, System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IUnaryNegationOperators<System::Numerics::BigInteger, System::Numerics::BigInteger>, System::Numerics::IUnaryPlusOperators<System::Numerics::BigInteger, System::Numerics::BigInteger>
public struct BigInteger : IComparable, IComparable<System.Numerics.BigInteger>, IEquatable<System.Numerics.BigInteger>, IFormattable
public readonly struct BigInteger : IComparable<System.Numerics.BigInteger>, IEquatable<System.Numerics.BigInteger>, IParsable<System.Numerics.BigInteger>, ISpanParsable<System.Numerics.BigInteger>, IUtf8SpanParsable<System.Numerics.BigInteger>, System.Numerics.IAdditionOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IAdditiveIdentity<System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IBinaryInteger<System.Numerics.BigInteger>, System.Numerics.IBinaryNumber<System.Numerics.BigInteger>, System.Numerics.IBitwiseOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IComparisonOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,bool>, System.Numerics.IDecrementOperators<System.Numerics.BigInteger>, System.Numerics.IDivisionOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IEqualityOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,bool>, System.Numerics.IIncrementOperators<System.Numerics.BigInteger>, System.Numerics.IModulusOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IMultiplicativeIdentity<System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IMultiplyOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.INumber<System.Numerics.BigInteger>, System.Numerics.INumberBase<System.Numerics.BigInteger>, System.Numerics.IShiftOperators<System.Numerics.BigInteger,int,System.Numerics.BigInteger>, System.Numerics.ISignedNumber<System.Numerics.BigInteger>, System.Numerics.ISubtractionOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IUnaryNegationOperators<System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IUnaryPlusOperators<System.Numerics.BigInteger,System.Numerics.BigInteger>
public readonly struct BigInteger : IComparable, IComparable<System.Numerics.BigInteger>, IEquatable<System.Numerics.BigInteger>, IFormattable
public readonly struct BigInteger : IComparable, IComparable<System.Numerics.BigInteger>, IEquatable<System.Numerics.BigInteger>, ISpanFormattable
public readonly struct BigInteger : IComparable<System.Numerics.BigInteger>, IEquatable<System.Numerics.BigInteger>, IParsable<System.Numerics.BigInteger>, ISpanParsable<System.Numerics.BigInteger>, System.Numerics.IAdditionOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IAdditiveIdentity<System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IBinaryInteger<System.Numerics.BigInteger>, System.Numerics.IBinaryNumber<System.Numerics.BigInteger>, System.Numerics.IBitwiseOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IComparisonOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,bool>, System.Numerics.IDecrementOperators<System.Numerics.BigInteger>, System.Numerics.IDivisionOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IEqualityOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,bool>, System.Numerics.IIncrementOperators<System.Numerics.BigInteger>, System.Numerics.IModulusOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IMultiplicativeIdentity<System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IMultiplyOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.INumber<System.Numerics.BigInteger>, System.Numerics.INumberBase<System.Numerics.BigInteger>, System.Numerics.IShiftOperators<System.Numerics.BigInteger,int,System.Numerics.BigInteger>, System.Numerics.ISignedNumber<System.Numerics.BigInteger>, System.Numerics.ISubtractionOperators<System.Numerics.BigInteger,System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IUnaryNegationOperators<System.Numerics.BigInteger,System.Numerics.BigInteger>, System.Numerics.IUnaryPlusOperators<System.Numerics.BigInteger,System.Numerics.BigInteger>
[System.Serializable]
public struct BigInteger : IComparable, IComparable<System.Numerics.BigInteger>, IEquatable<System.Numerics.BigInteger>, IFormattable
type BigInteger = struct
    interface IFormattable
type BigInteger = struct
    interface IFormattable
    interface IParsable<BigInteger>
    interface ISpanFormattable
    interface ISpanParsable<BigInteger>
    interface IAdditionOperators<BigInteger, BigInteger, BigInteger>
    interface IAdditiveIdentity<BigInteger, BigInteger>
    interface IBinaryInteger<BigInteger>
    interface IBinaryNumber<BigInteger>
    interface IBitwiseOperators<BigInteger, BigInteger, BigInteger>
    interface IComparisonOperators<BigInteger, BigInteger, bool>
    interface IEqualityOperators<BigInteger, BigInteger, bool>
    interface IDecrementOperators<BigInteger>
    interface IDivisionOperators<BigInteger, BigInteger, BigInteger>
    interface IIncrementOperators<BigInteger>
    interface IModulusOperators<BigInteger, BigInteger, BigInteger>
    interface IMultiplicativeIdentity<BigInteger, BigInteger>
    interface IMultiplyOperators<BigInteger, BigInteger, BigInteger>
    interface INumber<BigInteger>
    interface INumberBase<BigInteger>
    interface IUtf8SpanFormattable
    interface IUtf8SpanParsable<BigInteger>
    interface ISubtractionOperators<BigInteger, BigInteger, BigInteger>
    interface IUnaryNegationOperators<BigInteger, BigInteger>
    interface IUnaryPlusOperators<BigInteger, BigInteger>
    interface IShiftOperators<BigInteger, int, BigInteger>
    interface ISignedNumber<BigInteger>
type BigInteger = struct
    interface IFormattable
    interface IParsable<BigInteger>
    interface ISpanFormattable
    interface ISpanParsable<BigInteger>
    interface IUtf8SpanFormattable
    interface IUtf8SpanParsable<BigInteger>
    interface IAdditionOperators<BigInteger, BigInteger, BigInteger>
    interface IAdditiveIdentity<BigInteger, BigInteger>
    interface IBinaryInteger<BigInteger>
    interface IBinaryNumber<BigInteger>
    interface IBitwiseOperators<BigInteger, BigInteger, BigInteger>
    interface IComparisonOperators<BigInteger, BigInteger, bool>
    interface IEqualityOperators<BigInteger, BigInteger, bool>
    interface IDecrementOperators<BigInteger>
    interface IDivisionOperators<BigInteger, BigInteger, BigInteger>
    interface IIncrementOperators<BigInteger>
    interface IModulusOperators<BigInteger, BigInteger, BigInteger>
    interface IMultiplicativeIdentity<BigInteger, BigInteger>
    interface IMultiplyOperators<BigInteger, BigInteger, BigInteger>
    interface INumber<BigInteger>
    interface INumberBase<BigInteger>
    interface ISubtractionOperators<BigInteger, BigInteger, BigInteger>
    interface IUnaryNegationOperators<BigInteger, BigInteger>
    interface IUnaryPlusOperators<BigInteger, BigInteger>
    interface IShiftOperators<BigInteger, int, BigInteger>
    interface ISignedNumber<BigInteger>
type BigInteger = struct
    interface ISpanFormattable
    interface IFormattable
type BigInteger = struct
    interface IFormattable
    interface IParsable<BigInteger>
    interface ISpanFormattable
    interface ISpanParsable<BigInteger>
    interface IAdditionOperators<BigInteger, BigInteger, BigInteger>
    interface IAdditiveIdentity<BigInteger, BigInteger>
    interface IBinaryInteger<BigInteger>
    interface IBinaryNumber<BigInteger>
    interface IBitwiseOperators<BigInteger, BigInteger, BigInteger>
    interface IComparisonOperators<BigInteger, BigInteger, bool>
    interface IEqualityOperators<BigInteger, BigInteger, bool>
    interface IDecrementOperators<BigInteger>
    interface IDivisionOperators<BigInteger, BigInteger, BigInteger>
    interface IIncrementOperators<BigInteger>
    interface IModulusOperators<BigInteger, BigInteger, BigInteger>
    interface IMultiplicativeIdentity<BigInteger, BigInteger>
    interface IMultiplyOperators<BigInteger, BigInteger, BigInteger>
    interface INumber<BigInteger>
    interface INumberBase<BigInteger>
    interface ISubtractionOperators<BigInteger, BigInteger, BigInteger>
    interface IUnaryNegationOperators<BigInteger, BigInteger>
    interface IUnaryPlusOperators<BigInteger, BigInteger>
    interface IShiftOperators<BigInteger, int, BigInteger>
    interface ISignedNumber<BigInteger>
type BigInteger = struct
    interface IFormattable
    interface IParsable<BigInteger>
    interface ISpanFormattable
    interface ISpanParsable<BigInteger>
    interface IAdditionOperators<BigInteger, BigInteger, BigInteger>
    interface IAdditiveIdentity<BigInteger, BigInteger>
    interface IBinaryInteger<BigInteger>
    interface IBinaryNumber<BigInteger>
    interface IBitwiseOperators<BigInteger, BigInteger, BigInteger>
    interface IComparisonOperators<BigInteger, BigInteger, bool>
    interface IEqualityOperators<BigInteger, BigInteger, bool>
    interface IDecrementOperators<BigInteger>
    interface IDivisionOperators<BigInteger, BigInteger, BigInteger>
    interface IIncrementOperators<BigInteger>
    interface IModulusOperators<BigInteger, BigInteger, BigInteger>
    interface IMultiplicativeIdentity<BigInteger, BigInteger>
    interface IMultiplyOperators<BigInteger, BigInteger, BigInteger>
    interface INumber<BigInteger>
    interface INumberBase<BigInteger>
    interface ISubtractionOperators<BigInteger, BigInteger, BigInteger>
    interface IUnaryNegationOperators<BigInteger, BigInteger>
    interface IUnaryPlusOperators<BigInteger, BigInteger>
    interface IUtf8SpanFormattable
    interface IUtf8SpanParsable<BigInteger>
    interface IShiftOperators<BigInteger, int, BigInteger>
    interface ISignedNumber<BigInteger>
[<System.Serializable>]
type BigInteger = struct
    interface IFormattable
Public Structure BigInteger
Implements IComparable, IComparable(Of BigInteger), IEquatable(Of BigInteger), IFormattable
Public Structure BigInteger
Implements IAdditionOperators(Of BigInteger, BigInteger, BigInteger), IAdditiveIdentity(Of BigInteger, BigInteger), IBinaryInteger(Of BigInteger), IBinaryNumber(Of BigInteger), IBitwiseOperators(Of BigInteger, BigInteger, BigInteger), IComparable(Of BigInteger), IComparisonOperators(Of BigInteger, BigInteger, Boolean), IDecrementOperators(Of BigInteger), IDivisionOperators(Of BigInteger, BigInteger, BigInteger), IEqualityOperators(Of BigInteger, BigInteger, Boolean), IEquatable(Of BigInteger), IIncrementOperators(Of BigInteger), IModulusOperators(Of BigInteger, BigInteger, BigInteger), IMultiplicativeIdentity(Of BigInteger, BigInteger), IMultiplyOperators(Of BigInteger, BigInteger, BigInteger), INumber(Of BigInteger), INumberBase(Of BigInteger), IParsable(Of BigInteger), IShiftOperators(Of BigInteger, Integer, BigInteger), ISignedNumber(Of BigInteger), ISpanParsable(Of BigInteger), ISubtractionOperators(Of BigInteger, BigInteger, BigInteger), IUnaryNegationOperators(Of BigInteger, BigInteger), IUnaryPlusOperators(Of BigInteger, BigInteger), IUtf8SpanParsable(Of BigInteger)
Public Structure BigInteger
Implements IComparable, IComparable(Of BigInteger), IEquatable(Of BigInteger), ISpanFormattable
Public Structure BigInteger
Implements IAdditionOperators(Of BigInteger, BigInteger, BigInteger), IAdditiveIdentity(Of BigInteger, BigInteger), IBinaryInteger(Of BigInteger), IBinaryNumber(Of BigInteger), IBitwiseOperators(Of BigInteger, BigInteger, BigInteger), IComparable(Of BigInteger), IComparisonOperators(Of BigInteger, BigInteger, Boolean), IDecrementOperators(Of BigInteger), IDivisionOperators(Of BigInteger, BigInteger, BigInteger), IEqualityOperators(Of BigInteger, BigInteger, Boolean), IEquatable(Of BigInteger), IIncrementOperators(Of BigInteger), IModulusOperators(Of BigInteger, BigInteger, BigInteger), IMultiplicativeIdentity(Of BigInteger, BigInteger), IMultiplyOperators(Of BigInteger, BigInteger, BigInteger), INumber(Of BigInteger), INumberBase(Of BigInteger), IParsable(Of BigInteger), IShiftOperators(Of BigInteger, Integer, BigInteger), ISignedNumber(Of BigInteger), ISpanParsable(Of BigInteger), ISubtractionOperators(Of BigInteger, BigInteger, BigInteger), IUnaryNegationOperators(Of BigInteger, BigInteger), IUnaryPlusOperators(Of BigInteger, BigInteger)
継承
BigInteger
属性
実装
IComparable IComparable<BigInteger> IEquatable<BigInteger> IFormattable IComparable<TSelf> IEquatable<TSelf> IParsable<BigInteger> IParsable<TSelf> ISpanFormattable ISpanParsable<BigInteger> ISpanParsable<TSelf> IUtf8SpanFormattable IUtf8SpanParsable<BigInteger> IUtf8SpanParsable<TSelf> IAdditionOperators<BigInteger,BigInteger,BigInteger> IAdditionOperators<TSelf,TSelf,TSelf> IAdditiveIdentity<BigInteger,BigInteger> IAdditiveIdentity<TSelf,TSelf> IBinaryInteger<BigInteger> IBinaryNumber<BigInteger> IBinaryNumber<TSelf> IBitwiseOperators<BigInteger,BigInteger,BigInteger> IBitwiseOperators<TSelf,TSelf,TSelf> IComparisonOperators<BigInteger,BigInteger,Boolean> IComparisonOperators<TSelf,TSelf,Boolean> IDecrementOperators<BigInteger> IDecrementOperators<TSelf> IDivisionOperators<BigInteger,BigInteger,BigInteger> IDivisionOperators<TSelf,TSelf,TSelf> IEqualityOperators<BigInteger,BigInteger,Boolean> IEqualityOperators<TSelf,TOther,TResult> IEqualityOperators<TSelf,TSelf,Boolean> IIncrementOperators<BigInteger> IIncrementOperators<TSelf> IModulusOperators<BigInteger,BigInteger,BigInteger> IModulusOperators<TSelf,TSelf,TSelf> IMultiplicativeIdentity<BigInteger,BigInteger> IMultiplicativeIdentity<TSelf,TSelf> IMultiplyOperators<BigInteger,BigInteger,BigInteger> IMultiplyOperators<TSelf,TSelf,TSelf> INumber<BigInteger> INumber<TSelf> INumberBase<BigInteger> INumberBase<TSelf> IShiftOperators<BigInteger,Int32,BigInteger> IShiftOperators<TSelf,Int32,TSelf> ISignedNumber<BigInteger> ISubtractionOperators<BigInteger,BigInteger,BigInteger> ISubtractionOperators<TSelf,TSelf,TSelf> IUnaryNegationOperators<BigInteger,BigInteger> IUnaryNegationOperators<TSelf,TSelf> IUnaryPlusOperators<BigInteger,BigInteger> IUnaryPlusOperators<TSelf,TSelf>

注釈

BigInteger型は、理論上の値に上限または下限がない任意の大きな整数を表す不変型です。 BigInteger型のメンバーは、他の整数型 (ByteInt16Int32Int64SByteUInt16UInt32、およびUInt64型) のメンバーと密接に並行しています。 この型は、.NET の他の整数型とは異なり、 MinValue プロパティと MaxValue プロパティで示される範囲があります。

Note

BigInteger型は不変であるため (変更可能性を参照)、上限または下限がないため、OutOfMemoryException値が大きくなりすぎる操作に対してBigIntegerがスローされる可能性があります。

BigInteger オブジェクトをインスタンス化する

BigInteger オブジェクトは、いくつかの方法でインスタンス化できます。

  • new キーワードを使用し、任意の整数または浮動小数点値をパラメーターとしてBigIntegerコンストラクターに指定できます。 (浮動小数点値は、 BigIntegerに割り当てられる前に切り捨てられます)。次の例では、 new キーワードを使用して BigInteger 値をインスタンス化する方法を示します。

    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変数を宣言し、その値が整数型である限り、任意の数値型と同様に値を割り当てることができます。 次の例では、割り当てを使用して、BigIntegerから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 オブジェクトに 10 進値または浮動小数点値を割り当てることができます。 次の例では、(C# で) 明示的にキャストするか、(Visual Basic では) DoubleDecimal 値を 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
    

これらのメソッドを使用すると、既存の数値型のいずれか 1 つの範囲内にある値を持つ BigInteger オブジェクトをインスタンス化できます。 既存の数値型の範囲を超える値を持つ BigInteger オブジェクトは、次の 3 つの方法のいずれかでインスタンス化できます。

  • newキーワードを使用し、任意のサイズのバイト配列をBigInteger.BigIntegerコンストラクターに提供できます。 例えば次が挙げられます。

    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 {newBigInt} (or 0x{newBigInt:x}).");
    // The example displays the following output:
    //   The value of newBigInt is 4759477275222530853130 (or 0x102030405060708090a).
    
    Dim byteArray() As Byte = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
    Dim newBigInt As New BigInteger(byteArray)
    Console.WriteLine("The value of newBigInt is {0} (or 0x{0:x}).", newBigInt)
    ' The example displays the following output:
    '   The value of newBigInt is 4759477275222530853130 (or 0x102030405060708090a).
    
  • ParseメソッドまたはTryParse メソッドを呼び出して、数値の文字列形式をBigIntegerに変換できます。 例えば次が挙げられます。

    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 '{positiveString}' to a BigInteger value.");
    }
    
    if (BigInteger.TryParse(negativeString, out negBigInt))
      Console.WriteLine(negBigInt);
    else
       Console.WriteLine($"Unable to convert the string '{negativeString}' to a BigInteger value.");
    
    // 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メソッドを呼び出すことができます。 次の例では、UInt64.MaxValue を三乗し、結果を 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の初期化されていない値はZero

BigInteger 値に対して操作を実行する

他の整数型を使用する場合と同様に、 BigInteger インスタンスを使用できます。 BigInteger では、加算、減算、除算、乗算、単項否定などの基本的な算術演算を実行できるように、標準の数値演算子がオーバーロードされます。 標準の数値演算子を使用して、2 つの BigInteger 値を相互に比較することもできます。 他の整数型と同様に、 BigInteger ではビットごとの AndOrXOr、左シフト、右シフトの演算子もサポートされます。 カスタム演算子をサポートしていない言語の場合、 BigInteger 構造体には、数学演算を実行するための同等のメソッドも用意されています。 これには、 AddDivideMultiplyNegateSubtractなどがあります。

BigInteger構造体の多くのメンバーは、他の整数型のメンバーに直接対応します。 さらに、 BigInteger は次のようなメンバーを追加します。

これらの追加メンバーの多くは、プリミティブ数値型を操作する機能を提供する Math クラスのメンバーに対応しています。

変更可能性

次の例では、 BigInteger オブジェクトをインスタンス化し、その値を 1 ずつインクリメントします。

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)

この例では既存のオブジェクトの値を変更しているように見えますが、これは当てはまるわけではありません。 BigInteger オブジェクトは不変です。つまり、内部的には、共通言語ランタイムは実際に新しい BigInteger オブジェクトを作成し、前の値より 1 大きい値を割り当てます。 その後、この新しいオブジェクトが呼び出し元に返されます。

Note

.NET の他の数値型も変更できません。 ただし、 BigInteger 型には上限または下限がないため、値が非常に大きくなり、パフォーマンスに測定可能な影響を与える可能性があります。

このプロセスは呼び出し元には透過的ですが、パフォーマンス上のペナルティが発生します。 場合によっては、特に非常に大きな BigInteger 値に対して繰り返し操作がループで実行される場合、パフォーマンスの低下が大きくなる可能性があります。 たとえば、次の例では、100 万回まで操作が繰り返し実行され、操作が成功するたびに BigInteger 値が 1 ずつインクリメントされます。

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

このような場合は、 Int32 変数に対するすべての中間割り当てを実行することで、パフォーマンスを向上させることができます。 その後、ループが終了したときに、変数の最終的な値を BigInteger オブジェクトに割り当てることができます。 具体的な例を次に示します。

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

バイト配列と 16 進文字列

BigInteger値をバイト配列に変換する場合、またはバイト配列をBigInteger値に変換する場合は、バイトの順序を考慮する必要があります。 BigInteger構造体では、バイト配列内の個々のバイトがリトル エンディアン順 (つまり、値の下位バイトが上位バイトの前) で表示されることを想定しています。 次の例に示すように、BigInteger メソッドを呼び出し、結果のバイト配列を ToByteArray コンストラクターに渡すことで、BigInteger(Byte[])値をラウンドトリップできます。

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

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

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

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

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

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

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

他の整数型の値を表すバイト配列から BigInteger 値をインスタンス化するには、 BitConverter.GetBytes メソッドに整数値を渡し、結果のバイト配列を BigInteger(Byte[]) コンストラクターに渡します。 次の例では、BigInteger値を表すバイト配列からInt16値をインスタンス化します。

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構造体は、負の値が 2 の補数表現を使用して格納されることを前提としています。 BigInteger構造体は固定長のない数値を表しているため、BigInteger(Byte[]) コンストラクターは常に、配列内の最後のバイトの最上位ビットを符号ビットとして解釈します。 BigInteger(Byte[])コンストラクターが負の値の 2 つの補数表現を正の値の符号と大きさ表現と混同しないようにするには、通常、バイト配列の最後のバイトの最上位ビットが設定される正の値に、値が 0 の追加バイトを含める必要があります。 たとえば、0xC0 0xBD 0xF0 0xFFは、-1,000,000 または 4,293,967,296 のいずれかのリトル エンディアン 16 進数表現です。 この配列の最後のバイトの最上位ビットがオンであるため、バイト配列の値は、 BigInteger(Byte[]) コンストラクターによって -1,000,000 として解釈されます。 値が正の BigInteger をインスタンス化するには、要素が0xC0 0xBD 0xF0 0xFF 0x00バイト配列をコンストラクターに渡す必要があります。 次の例は、これを示しています。

int negativeNumber = -1000000;
uint positiveNumber = 4293967296;

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

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

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

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

正の値から ToByteArray メソッドによって作成されたバイト配列には、この余分な 0 値バイトが含まれます。 したがって、次の例に示すように、 BigInteger 構造体は、値をバイト配列に割り当ててから復元することで、値を正常にラウンドトリップできます。

BigInteger positiveValue = 15777216;
BigInteger negativeValue = -1000000;

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

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

Console.WriteLine();

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

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

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

ただし、開発者によって動的に作成されるバイト配列、または符号なし整数をバイト配列に変換するメソッド ( BitConverter.GetBytes(UInt16)BitConverter.GetBytes(UInt32)BitConverter.GetBytes(UInt64)など) によって返されるバイト配列に、この追加の 0 値バイトを追加する必要がある場合があります。

16 進数の文字列を解析する場合、 BigInteger.Parse(String, NumberStyles) メソッドと BigInteger.Parse(String, NumberStyles, IFormatProvider) メソッドは、文字列の最初のバイトの最上位ビットが設定されている場合、または文字列の最初の 16 進数がバイト値の下位 4 ビットを表す場合、値は 2 の補数表現を使用して表されることを前提としています。 たとえば、"FF01" と "F01" の両方が 10 進値 -255 を表します。 正の値と負の値を区別するには、正の値に先頭に 0 を含める必要があります。 ToString メソッドの関連するオーバーロードは、"X" 書式指定文字列を渡すときに、正の値を返す 16 進文字列に先頭に 0 を追加します。 これにより、次の例に示すように、BigInteger値をToStringメソッドとParseメソッドを使用してラウンドトリップできます。

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

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

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

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

ただし、他の整数型のToString メソッドを呼び出すことによって作成された 16 進数の文字列、またはToString パラメーターを含むtoBase メソッドのオーバーロードは、16 進数の文字列が派生した値またはソース データ型の符号を示すものではありません。 このような文字列から BigInteger 値を正常にインスタンス化するには、追加のロジックが必要です。 次の例では、1 つの可能な実装を示します。

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

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

public class ByteHexExample2
{
    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 {positiveNumber} to {hexValue1.Value} and back to {positiveBigInt}.");

        hexString = (hexValue2.Sign == 1 ? "0" : "") + hexValue2.Value;
        negativeBigInt = BigInteger.Parse(hexString, NumberStyles.HexNumber);
        Console.WriteLine($"Converted {negativeNumber} to {hexValue2.Value} and back to {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 Example2
    Public Sub Main()
        Dim positiveNumber As UInteger = 4039543321
        Dim negativeNumber As Integer = -255423975

        ' Convert the numbers to hex strings.
        Dim hexValue1, hexValue2 As HexValue
        hexValue1.Value = positiveNumber.ToString("X")
        hexValue1.Sign = Math.Sign(positiveNumber)

        hexValue2.Value = Convert.ToString(negativeNumber, 16)
        hexValue2.Sign = Math.Sign(negativeNumber)

        ' Round-trip the hexadecimal values to BigInteger values.
        Dim hexString As String
        Dim positiveBigInt, negativeBigInt As BigInteger

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

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

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

コンストラクター

名前 説明
BigInteger(Byte[])

バイト配列内の値を使用して、 BigInteger 構造体の新しいインスタンスを初期化します。

BigInteger(Decimal)

BigInteger値を使用して、Decimal構造体の新しいインスタンスを初期化します。

BigInteger(Double)

倍精度浮動小数点値を使用して、 BigInteger 構造体の新しいインスタンスを初期化します。

BigInteger(Int32)

32 ビット符号付き整数値を使用して、 BigInteger 構造体の新しいインスタンスを初期化します。

BigInteger(Int64)

64 ビット符号付き整数値を使用して、 BigInteger 構造体の新しいインスタンスを初期化します。

BigInteger(ReadOnlySpan<Byte>, Boolean, Boolean)

バイトの読み取り専用スパンの値を使用し、必要に応じて署名エンコードとエンディアンバイトオーダーを示して、 BigInteger 構造体の新しいインスタンスを初期化します。

BigInteger(Single)

単精度浮動小数点値を使用して、 BigInteger 構造体の新しいインスタンスを初期化します。

BigInteger(UInt32)

符号なし 32 ビット整数値を使用して、 BigInteger 構造体の新しいインスタンスを初期化します。

BigInteger(UInt64)

符号なし 64 ビット整数値を使用して、 BigInteger 構造体の新しいインスタンスを初期化します。

プロパティ

名前 説明
IsEven

現在の BigInteger オブジェクトの値が偶数かどうかを示します。

IsOne

現在の BigInteger オブジェクトの値が Oneされているかどうかを示します。

IsPowerOfTwo

現在の BigInteger オブジェクトの値が 2 の累乗であるかどうかを示します。

IsZero

現在の BigInteger オブジェクトの値が Zeroされているかどうかを示します。

MinusOne

負の 1 (-1) の数値を表す値を取得します。

One

数値 1 を表す値を取得します。

Sign

現在の BigInteger オブジェクトの符号 (負、正、またはゼロ) を示す数値を取得します。

Zero

数値 0 (ゼロ) を表す値を取得します。

メソッド

名前 説明
Abs(BigInteger)

BigInteger オブジェクトの絶対値を取得します。

Add(BigInteger, BigInteger)

2 つの BigInteger 値を追加し、結果を返します。

Clamp(BigInteger, BigInteger, BigInteger)

値を包括的な最小値と最大値にクランプします。

Compare(BigInteger, BigInteger)

2 つの BigInteger 値を比較し、最初の値が 2 番目の値より小さいか、等しいか、または大きいかを示す整数を返します。

CompareTo(BigInteger)

このインスタンスを 2 つ目の BigInteger と比較し、このインスタンスの値が指定したオブジェクトの値より小さいか、等しいか、または大きいかを示す整数を返します。

CompareTo(Int64)

このインスタンスを符号付き 64 ビット整数と比較し、このインスタンスの値が符号付き 64 ビット整数の値より小さいか、等しいか、または大きいかを示す整数を返します。

CompareTo(Object)

このインスタンスを指定したオブジェクトと比較し、このインスタンスの値が指定したオブジェクトの値より小さいか、等しいか、または大きいかを示す整数を返します。

CompareTo(UInt64)

このインスタンスを符号なし 64 ビット整数と比較し、このインスタンスの値が符号なし 64 ビット整数の値より小さいか、等しいか、または大きいかを示す整数を返します。

CopySign(BigInteger, BigInteger)

値の符号を別の値の符号にコピーします。

CreateChecked<TOther>(TOther)

現在の型のインスタンスを値から作成し、現在の型の表現可能範囲外の値に対してオーバーフロー例外をスローします。

CreateSaturating<TOther>(TOther)

現在の型のインスタンスを値から作成し、現在の型の表現可能な範囲外の値を飽和させます。

CreateTruncating<TOther>(TOther)

現在の型のインスタンスを値から作成し、現在の型の表現可能範囲外の値を切り捨てます。

Divide(BigInteger, BigInteger)

1 つの BigInteger 値を別の値で除算し、結果を返します。

DivRem(BigInteger, BigInteger, BigInteger)

1 つの BigInteger 値を別の値で除算し、結果を返し、出力パラメーターで剰余を返します。

DivRem(BigInteger, BigInteger)

2 つの値の商と剰余を計算します。

Equals(BigInteger)

現在のインスタンスと指定した BigInteger オブジェクトが同じ値を持っているかどうかを示す値を返します。

Equals(Int64)

現在のインスタンスと符号付き 64 ビット整数の値が同じかどうかを示す値を返します。

Equals(Object)

現在のインスタンスと指定したオブジェクトの値が同じかどうかを示す値を返します。

Equals(UInt64)

現在のインスタンスと符号なし 64 ビット整数の値が同じかどうかを示す値を返します。

GetBitLength()

符号ビットのない現在のインスタンスの最短 2 の補数表現に必要なビット数を取得します。

GetByteCount(Boolean)

ToByteArray(Boolean, Boolean)およびTryWriteBytes(Span<Byte>, Int32, Boolean, Boolean)によって出力されるバイト数を取得します。

GetHashCode()

現在の BigInteger オブジェクトのハッシュ コードを返します。

GreatestCommonDivisor(BigInteger, BigInteger)

2 つの BigInteger 値の最大の共通除数を検索します。

IsEvenInteger(BigInteger)

値が偶数の整数を表すかどうかを判断します。

IsNegative(BigInteger)

値が負の値かどうかを判断します。

IsOddInteger(BigInteger)

値が奇数の整数を表すかどうかを判断します。

IsPositive(BigInteger)

値が正かどうかを判断します。

IsPow2(BigInteger)

値が 2 の累乗であるかどうかを判断します。

LeadingZeroCount(BigInteger)

値の先頭のゼロの数を計算します。

Log(BigInteger, Double)

指定した底の指定した数値の対数を返します。

Log(BigInteger)

指定した数値の自然対数 (底 e) を返します。

Log10(BigInteger)

指定した数値の底 10 の対数を返します。

Log2(BigInteger)

値の log2 を計算します。

Max(BigInteger, BigInteger)

2 つの BigInteger 値のうち大きい方を返します。

MaxMagnitude(BigInteger, BigInteger)

2 つの値を、より大きいコンピューティングと比較します。

Min(BigInteger, BigInteger)

2 つの BigInteger 値のうち小さい方を返します。

MinMagnitude(BigInteger, BigInteger)

2 つの値を比較して計算します。計算の方が少なくなります。

ModPow(BigInteger, BigInteger, BigInteger)

別の数値の累乗に引き上げられた数値に対して剰余除算を実行します。

Multiply(BigInteger, BigInteger)

2 つの BigInteger 値の積を返します。

Negate(BigInteger)

指定した BigInteger 値を否定します。

Parse(ReadOnlySpan<Byte>, IFormatProvider)

任意の大きい符号付き整数を表します。

Parse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider)

任意の大きい符号付き整数を表します。

Parse(ReadOnlySpan<Char>, IFormatProvider)

文字のスパンを値に解析します。

Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)

指定したスタイルで、指定した文字の読み取り専用スパンに含まれる数値の表現を、同等の BigInteger に変換します。

Parse(String, IFormatProvider)

指定したカルチャ固有の形式の数値の文字列形式を、同等の BigInteger に変換します。

Parse(String, NumberStyles, IFormatProvider)

指定したスタイルおよびカルチャ固有の形式の数値の文字列形式を、同等の BigInteger に変換します。

Parse(String, NumberStyles)

指定したスタイルの数値の文字列形式を等価の BigInteger に変換します。

Parse(String)

数値の文字列形式を等価の BigInteger に変換します。

PopCount(BigInteger)

値に設定されているビット数を計算します。

Pow(BigInteger, Int32)

BigInteger値を指定した値の累乗に引き上げます。

Remainder(BigInteger, BigInteger)

2 つの BigInteger 値に対して整数除算を実行し、剰余を返します。

RotateLeft(BigInteger, Int32)

指定した量の値を左に回転します。

RotateRight(BigInteger, Int32)

指定した量の値を右に回転します。

Subtract(BigInteger, BigInteger)

1 つの BigInteger 値を別の値から減算し、結果を返します。

ToByteArray()

BigInteger値をバイト配列に変換します。

ToByteArray(Boolean, Boolean)

可能な限り少ないバイト数を使用して、この BigInteger の値をバイト配列として返します。 値が 0 の場合は、要素が0x00された 1 バイトの配列を返します。

ToString()

現在の BigInteger オブジェクトの数値を等価の文字列形式に変換します。

ToString(IFormatProvider)

指定したカルチャ固有の書式設定情報を使用して、現在の BigInteger オブジェクトの数値を等価の文字列形式に変換します。

ToString(String, IFormatProvider)

現在の BigInteger オブジェクトの数値を、指定した書式およびカルチャ固有の書式情報を使用して、等価の文字列形式に変換します。

ToString(String)

指定した形式を使用して、現在の BigInteger オブジェクトの数値を等価の文字列形式に変換します。

TrailingZeroCount(BigInteger)

値の末尾のゼロの数を計算します。

TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider)

任意の大きい符号付き整数を表します。

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

この大きな整数インスタンスを文字のスパンに書式設定します。

TryParse(ReadOnlySpan<Byte>, BigInteger)

任意の大きい符号付き整数を表します。

TryParse(ReadOnlySpan<Byte>, IFormatProvider, BigInteger)

任意の大きい符号付き整数を表します。

TryParse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider, BigInteger)

任意の大きい符号付き整数を表します。

TryParse(ReadOnlySpan<Char>, BigInteger)

指定した読み取り専用文字スパンに含まれる数値の表現を等価の BigInteger に変換し、変換が成功したかどうかを示す値を返します。

TryParse(ReadOnlySpan<Char>, IFormatProvider, BigInteger)

文字のスパンを値に解析しようとします。

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

数値の文字列形式を等価の BigInteger に変換し、変換が成功したかどうかを示す値を返します。

TryParse(String, BigInteger)

数値の文字列形式を等価の BigInteger に変換し、変換が成功したかどうかを示す値を返します。

TryParse(String, IFormatProvider, BigInteger)

文字列を値に解析しようとします。

TryParse(String, NumberStyles, IFormatProvider, BigInteger)

指定したスタイルおよびカルチャ固有の形式の数値の文字列形式を等価の BigInteger に変換し、変換が成功したかどうかを示す値を返します。

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

可能な限り少ないバイト数を使用して、この BigInteger の値をリトル エンディアンの 2 補数バイトとしてコピーします。 値が 0 の場合、要素が0x00されている 1 バイトを出力します。

演算子

名前 説明
Addition(BigInteger, BigInteger)

指定した 2 つの BigInteger オブジェクトの値を追加します。

BitwiseAnd(BigInteger, BigInteger)

2 つのAnd値に対してビットごとのBigInteger演算を実行します。

BitwiseOr(BigInteger, BigInteger)

2 つのOr値に対してビットごとのBigInteger演算を実行します。

Decrement(BigInteger)

BigInteger値を 1 ずつデクリメントします。

Division(BigInteger, BigInteger)

整数除算を使用して、指定した BigInteger 値を別の指定した BigInteger 値で除算します。

Equality(BigInteger, BigInteger)

2 つの BigInteger オブジェクトの値が等しいかどうかを示す値を返します。

Equality(BigInteger, Int64)

BigInteger値と符号付き long 整数値が等しいかどうかを示す値を返します。

Equality(BigInteger, UInt64)

BigInteger値と符号なし long 整数値が等しいかどうかを示す値を返します。

Equality(Int64, BigInteger)

符号付き long 整数値と BigInteger 値が等しいかどうかを示す値を返します。

Equality(UInt64, BigInteger)

符号なし long 整数値と BigInteger 値が等しいかどうかを示す値を返します。

ExclusiveOr(BigInteger, BigInteger)

2 つのOr値に対してビットごとの排他的XOr (BigInteger) 演算を実行します。

Explicit(BFloat16 to BigInteger)

任意の大きい符号付き整数を表します。

Explicit(BigInteger to BFloat16)

任意の大きい符号付き整数を表します。

Explicit(BigInteger to Byte)

BigInteger オブジェクトから符号なしバイト値への明示的な変換を定義します。

Explicit(BigInteger to Char)

大きな整数を Char 値に明示的に変換します。

Explicit(BigInteger to Decimal)

BigInteger オブジェクトからDecimal値への明示的な変換を定義します。

Explicit(BigInteger to Double)

BigInteger オブジェクトからDouble値への明示的な変換を定義します。

Explicit(BigInteger to Half)

大きな整数を Half 値に明示的に変換します。

Explicit(BigInteger to Int128)

大きな整数を Int128 値に明示的に変換します。

Explicit(BigInteger to Int16)

BigInteger オブジェクトから 16 ビット符号付き整数値への明示的な変換を定義します。

Explicit(BigInteger to Int32)

BigInteger オブジェクトから 32 ビット符号付き整数値への明示的な変換を定義します。

Explicit(BigInteger to Int64)

BigInteger オブジェクトから 64 ビット符号付き整数値への明示的な変換を定義します。

Explicit(BigInteger to IntPtr)

大きな整数を IntPtr 値に明示的に変換します。

Explicit(BigInteger to SByte)

BigInteger オブジェクトから符号付き 8 ビット値への明示的な変換を定義します。

この API は CLS 準拠ではありません。 準拠している代替手段は Int16

Explicit(BigInteger to Single)

BigInteger オブジェクトから単精度浮動小数点値への明示的な変換を定義します。

Explicit(BigInteger to UInt128)

大きな整数を UInt128 値に明示的に変換します。

Explicit(BigInteger to UInt16)

BigInteger オブジェクトから符号なし 16 ビット整数値への明示的な変換を定義します。

この API は CLS 準拠ではありません。 準拠している代替手段は Int32

Explicit(BigInteger to UInt32)

BigInteger オブジェクトから符号なし 32 ビット整数値への明示的な変換を定義します。

この API は CLS 準拠ではありません。 準拠している代替手段は Int64

Explicit(BigInteger to UInt64)

BigInteger オブジェクトから符号なし 64 ビット整数値への明示的な変換を定義します。

この API は CLS 準拠ではありません。 準拠している代替手段は Double

Explicit(BigInteger to UIntPtr)

大きな整数を UIntPtr 値に明示的に変換します。

Explicit(Complex to BigInteger)

Complex値を整数に明示的に変換します。

Explicit(Decimal to BigInteger)

Decimal オブジェクトからBigInteger値への明示的な変換を定義します。

Explicit(Double to BigInteger)

Double値からBigInteger値への明示的な変換を定義します。

Explicit(Half to BigInteger)

Half値を整数に明示的に変換します。

Explicit(Single to BigInteger)

Single値からBigInteger値への明示的な変換を定義します。

GreaterThan(BigInteger, BigInteger)

BigInteger値が別のBigInteger値より大きいかどうかを示す値を返します。

GreaterThan(BigInteger, Int64)

BigIntegerが 64 ビット符号付き整数値より大きいかどうかを示す値を返します。

GreaterThan(BigInteger, UInt64)

BigInteger値が 64 ビット符号なし整数より大きいかどうかを示す値を返します。

GreaterThan(Int64, BigInteger)

64 ビット符号付き整数が BigInteger 値より大きいかどうかを示す値を返します。

GreaterThan(UInt64, BigInteger)

BigInteger値が 64 ビット符号なし整数より大きいかどうかを示す値を返します。

GreaterThanOrEqual(BigInteger, BigInteger)

BigInteger値が別のBigInteger値以上かどうかを示す値を返します。

GreaterThanOrEqual(BigInteger, Int64)

BigInteger値が 64 ビット符号付き整数値以上かどうかを示す値を返します。

GreaterThanOrEqual(BigInteger, UInt64)

BigInteger値が 64 ビット符号なし整数値以上かどうかを示す値を返します。

GreaterThanOrEqual(Int64, BigInteger)

64 ビット符号付き整数が BigInteger 値以上かどうかを示す値を返します。

GreaterThanOrEqual(UInt64, BigInteger)

64 ビット符号なし整数が BigInteger 値以上かどうかを示す値を返します。

Implicit(Byte to BigInteger)

符号なしバイトから BigInteger 値への暗黙的な変換を定義します。

Implicit(Char to BigInteger)

Char値を整数に暗黙的に変換します。

Implicit(Int128 to BigInteger)

Int128値を整数に暗黙的に変換します。

Implicit(Int16 to BigInteger)

符号付き 16 ビット整数から BigInteger 値への暗黙的な変換を定義します。

Implicit(Int32 to BigInteger)

符号付き 32 ビット整数から BigInteger 値への暗黙的な変換を定義します。

Implicit(Int64 to BigInteger)

符号付き 64 ビット整数から BigInteger 値への暗黙的な変換を定義します。

Implicit(IntPtr to BigInteger)

IntPtr値を整数に暗黙的に変換します。

Implicit(SByte to BigInteger)

8 ビット符号付き整数から BigInteger 値への暗黙的な変換を定義します。

この API は CLS 準拠ではありません。 準拠している代替手段は BigInteger(Int32)

Implicit(UInt128 to BigInteger)

UInt128値を整数に暗黙的に変換します。

Implicit(UInt16 to BigInteger)

16 ビット符号なし整数から BigInteger 値への暗黙的な変換を定義します。

この API は CLS 準拠ではありません。 準拠している代替手段は Implicit(Int32 to BigInteger)

Implicit(UInt32 to BigInteger)

32 ビット符号なし整数から BigInteger 値への暗黙的な変換を定義します。

この API は CLS 準拠ではありません。 準拠している代替手段は Implicit(Int64 to BigInteger)

Implicit(UInt64 to BigInteger)

64 ビット符号なし整数から BigInteger 値への暗黙的な変換を定義します。

この API は CLS 準拠ではありません。 準拠している代替手段は Double

Implicit(UIntPtr to BigInteger)

UIntPtr値を整数に暗黙的に変換します。

Increment(BigInteger)

BigInteger値を 1 ずつインクリメントします。

Inequality(BigInteger, BigInteger)

2 つの BigInteger オブジェクトの値が異なるかどうかを示す値を返します。

Inequality(BigInteger, Int64)

BigInteger値と 64 ビット符号付き整数が等しくないかどうかを示す値を返します。

Inequality(BigInteger, UInt64)

BigInteger値と 64 ビット符号なし整数が等しくないかどうかを示す値を返します。

Inequality(Int64, BigInteger)

64 ビット符号付き整数と BigInteger 値が等しくないかどうかを示す値を返します。

Inequality(UInt64, BigInteger)

64 ビット符号なし整数と BigInteger 値が等しくないかどうかを示す値を返します。

LeftShift(BigInteger, Int32)

BigInteger値を指定したビット数だけ左にシフトします。

LessThan(BigInteger, BigInteger)

BigInteger値が別のBigInteger値より小さいかどうかを示す値を返します。

LessThan(BigInteger, Int64)

BigInteger値が 64 ビット符号付き整数未満かどうかを示す値を返します。

LessThan(BigInteger, UInt64)

BigInteger値が 64 ビット符号なし整数未満かどうかを示す値を返します。

LessThan(Int64, BigInteger)

64 ビット符号付き整数が BigInteger 値より小さいかどうかを示す値を返します。

LessThan(UInt64, BigInteger)

64 ビット符号なし整数が BigInteger 値より小さいかどうかを示す値を返します。

LessThanOrEqual(BigInteger, BigInteger)

BigInteger値が別のBigInteger値以下かどうかを示す値を返します。

LessThanOrEqual(BigInteger, Int64)

BigInteger値が 64 ビット符号付き整数以下かどうかを示す値を返します。

LessThanOrEqual(BigInteger, UInt64)

BigInteger値が 64 ビット符号なし整数以下かどうかを示す値を返します。

LessThanOrEqual(Int64, BigInteger)

64 ビット符号付き整数が BigInteger 値以下かどうかを示す値を返します。

LessThanOrEqual(UInt64, BigInteger)

64 ビット符号なし整数が BigInteger 値以下かどうかを示す値を返します。

Modulus(BigInteger, BigInteger)

指定した 2 つの BigInteger 値を持つ除算の結果の剰余を返します。

Multiply(BigInteger, BigInteger)

指定した 2 つの BigInteger 値を乗算します。

OnesComplement(BigInteger)

BigInteger値のビットごとの 1 の補数を返します。

RightShift(BigInteger, Int32)

BigInteger値を指定したビット数だけ右にシフトします。

Subtraction(BigInteger, BigInteger)

別のBigInteger値からBigInteger値を減算します。

UnaryNegation(BigInteger)

指定した BigInteger 値を否定します。

UnaryPlus(BigInteger)

BigInteger オペランドの値を返します。 (オペランドの符号は変更されません。

UnsignedRightShift(BigInteger, Int32)

指定した量で値を右にシフトします。

明示的なインターフェイスの実装

名前 説明
IAdditiveIdentity<BigInteger,BigInteger>.AdditiveIdentity

現在の型の加法 ID を取得します。

IBinaryInteger<BigInteger>.GetByteCount()

TryWriteLittleEndian(Span<Byte>, Int32)の一部として書き込まれるバイト数を取得します。

IBinaryInteger<BigInteger>.GetShortestBitLength()

現在の値の最短 2 の補数表現の長さをビット単位で取得します。

IBinaryInteger<BigInteger>.Log10(BigInteger)

任意の大きい符号付き整数を表します。

IBinaryInteger<BigInteger>.TryReadBigEndian(ReadOnlySpan<Byte>, Boolean, BigInteger)

任意の大きい符号付き整数を表します。

IBinaryInteger<BigInteger>.TryReadLittleEndian(ReadOnlySpan<Byte>, Boolean, BigInteger)

任意の大きい符号付き整数を表します。

IBinaryInteger<BigInteger>.TryWriteBigEndian(Span<Byte>, Int32)

ビッグ エンディアン形式の現在の値を特定のスパンに書き込もうとします。

IBinaryInteger<BigInteger>.TryWriteLittleEndian(Span<Byte>, Int32)

現在の値をリトル エンディアン形式で特定のスパンに書き込もうとします。

IBinaryNumber<BigInteger>.AllBitsSet

すべてのビットが設定されているバイナリ型のインスタンスを取得します。

IComparable.CompareTo(Object)

このインスタンスを指定したオブジェクトと比較し、このインスタンスの値が指定したオブジェクトの値より小さいか、等しいか、または大きいかを示す整数を返します。

IMultiplicativeIdentity<BigInteger,BigInteger>.MultiplicativeIdentity

現在の型の乗法 ID を取得します。

INumber<BigInteger>.MaxNumber(BigInteger, BigInteger)

2 つの値を比較して、大きい値を計算し、1 つの入力が NaN場合はもう一方の値を返します。

INumber<BigInteger>.MinNumber(BigInteger, BigInteger)

2 つの値を比較して計算します。この値は小さく、一方の入力が NaN場合はもう一方の値を返します。

INumber<BigInteger>.Sign(BigInteger)

値の符号を計算します。

INumberBase<BigInteger>.IsCanonical(BigInteger)

値が正規表現内にあるかどうかを判断します。

INumberBase<BigInteger>.IsComplexNumber(BigInteger)

値が複素数を表すかどうかを判断します。

INumberBase<BigInteger>.IsFinite(BigInteger)

値が有限かどうかを判断します。

INumberBase<BigInteger>.IsImaginaryNumber(BigInteger)

値が純粋な虚数を表すかどうかを判断します。

INumberBase<BigInteger>.IsInfinity(BigInteger)

値が無限かどうかを判断します。

INumberBase<BigInteger>.IsInteger(BigInteger)

値が整数を表すかどうかを判断します。

INumberBase<BigInteger>.IsNaN(BigInteger)

値が NaN かどうかを判断します。

INumberBase<BigInteger>.IsNegativeInfinity(BigInteger)

値が負の無限大かどうかを判断します。

INumberBase<BigInteger>.IsNormal(BigInteger)

値が正常かどうかを判断します。

INumberBase<BigInteger>.IsPositiveInfinity(BigInteger)

値が正の無限大かどうかを判断します。

INumberBase<BigInteger>.IsRealNumber(BigInteger)

値が実数を表すかどうかを判断します。

INumberBase<BigInteger>.IsSubnormal(BigInteger)

値が非正規かどうかを判断します。

INumberBase<BigInteger>.IsZero(BigInteger)

値が 0 かどうかを判断します。

INumberBase<BigInteger>.MaxMagnitudeNumber(BigInteger, BigInteger)

2 つの値を比較して、大きさが大きい計算を行い、一方の入力が NaN場合はもう一方の値を返します。

INumberBase<BigInteger>.MinMagnitudeNumber(BigInteger, BigInteger)

2 つの値を比較して、大きさが小さい計算を行い、一方の入力が NaN場合はもう一方の値を返します。

INumberBase<BigInteger>.MultiplyAddEstimate(BigInteger, BigInteger, BigInteger)

(left * right) + addendの推定値を計算します。

INumberBase<BigInteger>.Radix

型の基数 (底) を取得します。

INumberBase<BigInteger>.TryConvertFromChecked<TOther>(TOther, BigInteger)

任意の大きい符号付き整数を表します。

INumberBase<BigInteger>.TryConvertFromSaturating<TOther>(TOther, BigInteger)

任意の大きい符号付き整数を表します。

INumberBase<BigInteger>.TryConvertFromTruncating<TOther>(TOther, BigInteger)

任意の大きい符号付き整数を表します。

INumberBase<BigInteger>.TryConvertToChecked<TOther>(BigInteger, TOther)

現在の型のインスタンスを別の型に変換しようと試み、現在の型の表現可能な範囲外の値に対してオーバーフロー例外をスローします。

INumberBase<BigInteger>.TryConvertToSaturating<TOther>(BigInteger, TOther)

現在の型のインスタンスを別の型に変換しようとします。現在の型の表現可能な範囲外の値が飽和状態になります。

INumberBase<BigInteger>.TryConvertToTruncating<TOther>(BigInteger, TOther)

現在の型のインスタンスを別の型に変換し、現在の型の表現可能な範囲外の値を切り捨てようとします。

ISignedNumber<BigInteger>.NegativeOne

型の -1 値を取得します。

適用対象