BigInteger 생성자

정의

BigInteger 구조체의 새 인스턴스를 초기화합니다.

오버로드

BigInteger(Byte[])

바이트 배열의 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

BigInteger(Decimal)

BigInteger 값을 사용하여 Decimal 구조체의 새 인스턴스를 초기화합니다.

BigInteger(Double)

배정밀도 부동 소수점 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

BigInteger(Int32)

부호 있는 32비트 정수 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

BigInteger(Int64)

부호 있는 64비트 정수 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

BigInteger(Single)

단정밀도 부동 소수점 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

BigInteger(UInt32)

부호 없는 32비트 정수 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

BigInteger(UInt64)

부호 없는 64비트 정수 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

BigInteger(ReadOnlySpan<Byte>, Boolean, Boolean)

읽기 전용 바이트 범위의 값을 사용하고 선택적으로 서명 인코딩 및 endian 바이트 순서를 나타내는 BigInteger 구조체의 새 인스턴스를 초기화합니다.

BigInteger(Byte[])

Source:
BigInteger.cs
Source:
BigInteger.cs
Source:
BigInteger.cs

중요

이 API는 CLS 규격이 아닙니다.

바이트 배열의 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

public:
 BigInteger(cli::array <System::Byte> ^ value);
[System.CLSCompliant(false)]
public BigInteger (byte[] value);
[<System.CLSCompliant(false)>]
new System.Numerics.BigInteger : byte[] -> System.Numerics.BigInteger
Public Sub New (value As Byte())

매개 변수

value
Byte[]

little-endian 순서로 된 바이트 값의 배열입니다.

특성

예외

value이(가) null인 경우

예제

다음 예제에서는 값이 {5, 4, 3, 2, 1}인 5개 요소 바이트 배열에서 개체를 인스턴스화 BigInteger 합니다. 그런 다음 10진수와 16진수로 표시된 값을 콘솔에 표시 BigInteger 합니다. 입력 배열을 텍스트 출력과 비교하면 클래스 생성자의 이 오버로드 BigInteger 가 값이 4328719365(또는 0x102030405)인 개체를 만드는 BigInteger 이유를 명확하게 알 수 있습니다. 값이 5인 바이트 배열의 첫 번째 요소는 0x05 개체의 BigInteger 가장 낮은 바이트 값을 정의합니다. 값이 4인 바이트 배열의 두 번째 요소는 0x04 개체의 BigInteger 두 번째 바이트 값을 정의합니다.

byte[] bytes = { 5, 4, 3, 2, 1 };
BigInteger number = new BigInteger(bytes);
Console.WriteLine("The value of number is {0} (or 0x{0:x}).", number);
// The example displays the following output:
//    The value of number is 4328719365 (or 0x102030405).
Dim bytes() As Byte = { 5, 4, 3, 2, 1 }
Dim number As New BigInteger(bytes)
Console.WriteLine("The value of number is {0} (or 0x{0:x}).", number) 
' The example displays the following output:
'    The value of number is 4328719365 (or 0x102030405).

다음 예제에서는 양수 및 음 BigInteger 수 값을 인스턴스화하고 메서드에 ToByteArray 전달한 다음 결과 바이트 배열에서 원래 BigInteger 값을 복원합니다. 두 값은 동일한 바이트 배열로 표시됩니다. 둘 사이의 유일한 차이점은 바이트 배열의 마지막 요소 중 가장 중요한 비트에 있습니다. 배열이 음 BigInteger 수 값에서 만들어지면 이 비트가 설정됩니다(바이트의 값은 0xFF). 배열이 양수 BigInteger 값에서 만들어지면 비트가 설정되지 않습니다(바이트 값은 0임).

// Instantiate BigInteger values.
BigInteger positiveValue = BigInteger.Parse("4713143110832790377889");
BigInteger negativeValue = BigInteger.Add(-Int64.MaxValue, -60000);
BigInteger positiveValue2, negativeValue2;

// Create two byte arrays.
byte[] positiveBytes = positiveValue.ToByteArray();
byte[] negativeBytes = negativeValue.ToByteArray();

// Instantiate new BigInteger from negativeBytes array.
Console.Write("Converted {0:N0} to the byte array ", negativeValue);
foreach (byte byteValue in negativeBytes)
   Console.Write("{0:X2} ", byteValue);
Console.WriteLine();
negativeValue2 = new BigInteger(negativeBytes);
Console.WriteLine("Converted the byte array to {0:N0}", negativeValue2);
Console.WriteLine();

// Instantiate new BigInteger from positiveBytes array.
Console.Write("Converted {0:N0} to the byte array ", positiveValue);
foreach (byte byteValue in positiveBytes)
   Console.Write("{0:X2} ", byteValue);
Console.WriteLine();
positiveValue2 = new BigInteger(positiveBytes);
Console.WriteLine("Converted the byte array to {0:N0}", positiveValue2);
Console.WriteLine();
// The example displays the following output:
//    Converted -9,223,372,036,854,835,807 to the byte array A1 15 FF FF FF FF FF 7F FF
//    Converted the byte array to -9,223,372,036,854,835,807
//
//    Converted 4,713,143,110,832,790,377,889 to the byte array A1 15 FF FF FF FF FF 7F FF 00
//    Converted the byte array to 4,713,143,110,832,790,377,889
' Instantiate BigInteger values.
Dim positiveValue As BigInteger = BigInteger.Parse("4713143110832790377889")
Dim negativeValue As BigInteger = BigInteger.Add(-Int64.MaxValue, -60000) 
Dim positiveValue2, negativeValue2 As BigInteger

' Create two byte arrays.
Dim positiveBytes() As Byte = positiveValue.ToByteArray()
Dim negativeBytes() As Byte = negativeValue.ToByteArray()

' Instantiate new BigInteger from negativeBytes array.
Console.Write("Converted {0:N0} to the byte array ", negativeValue)
For Each byteValue As Byte In negativeBytes
   Console.Write("{0:X2} ", byteValue)
Next 
Console.WriteLine()
negativeValue2 = New BigInteger(negativeBytes)
Console.WriteLine("Converted the byte array to {0:N0}", negativeValue2)
Console.WriteLine()

' Instantiate new BigInteger from positiveBytes array.
Console.Write("Converted {0:N0} to the byte array ", positiveValue)
For Each byteValue As Byte In positiveBytes
   Console.Write("{0:X2} ", byteValue)
Next 
Console.WriteLine()
positiveValue2 = New BigInteger(positiveBytes)
Console.WriteLine("Converted the byte array to {0:N0}", positiveValue2)
Console.WriteLine()
' The example displays the following output:
'    Converted -9,223,372,036,854,835,807 to the byte array A1 15 FF FF FF FF FF 7F FF
'    Converted the byte array to -9,223,372,036,854,835,807
'    
'    Converted 4,713,143,110,832,790,377,889 to the byte array A1 15 FF FF FF FF FF 7F FF 00
'    Converted the byte array to 4,713,143,110,832,790,377,889

다음 예제에서는 값이 0인 바이트를 배열 끝에 추가하여 양수 값이 음수 값으로 잘못 인스턴스화되지 않도록 하는 방법을 보여 줍니다.

ulong originalNumber = UInt64.MaxValue;
byte[] bytes = BitConverter.GetBytes(originalNumber);
if (originalNumber > 0 && (bytes[bytes.Length - 1] & 0x80) > 0)
{
   byte[] temp = new byte[bytes.Length];
   Array.Copy(bytes, temp, bytes.Length);
   bytes = new byte[temp.Length + 1];
   Array.Copy(temp, bytes, temp.Length);
}

BigInteger newNumber = new BigInteger(bytes);
Console.WriteLine("Converted the UInt64 value {0:N0} to {1:N0}.",
                  originalNumber, newNumber);
// The example displays the following output:
//    Converted the UInt64 value 18,446,744,073,709,551,615 to 18,446,744,073,709,551,615.
Dim originalNumber As ULong = UInt64.MaxValue
' Convert an unsigned integer to a byte array.
Dim bytes() As Byte = BitConverter.GetBytes(originalNumber)
' Determine whether the MSB of the highest-order byte is set.
If originalNumber > 0 And (bytes(bytes.Length - 1) And &h80) > 0 Then
   ' If the MSB is set, add one zero-value byte to the end of the array.
   ReDim Preserve bytes(bytes.Length)
End If

Dim newNumber As New BigInteger(bytes)
Console.WriteLine("Converted the UInt64 value {0:N0} to {1:N0}.", 
                  originalNumber, newNumber) 
' The example displays the following output:
'    Converted the UInt64 value 18,446,744,073,709,551,615 to 18,446,744,073,709,551,615.

설명

배열의 value 개별 바이트는 가장 낮은 바이트에서 가장 높은 바이트까지 little-endian 순서여야 합니다. 예를 들어 숫자 값 1,000,000,000,000은 다음 표와 같이 표시됩니다.

16진수 문자열 E8D4A51000
바이트 배열(가장 낮은 인덱스 우선) 00 10 A5 D4 E8 00

숫자 값을 및 와 같은 바이트 배열로 BigInteger.ToByteArrayBitConverter.GetBytes변환하는 대부분의 메서드는 little-endian 순서로 바이트 배열을 반환합니다.

생성자는 바이트 배열의 양수 값이 부호 및 크기 표현을 사용하고 음수 값이 두 개의 보수 표현을 사용할 것으로 예상합니다. 즉, 에서 가장 높은 순서 바이트의 value 최상위 비트가 설정된 경우 결과 BigInteger 값은 음수입니다. 바이트 배열의 원본에 따라 양수 값이 음수 값으로 잘못 해석될 수 있습니다. 바이트 배열은 일반적으로 다음과 같은 방법으로 생성됩니다.

  • BigInteger.ToByteArray 메서드 호출. 이 메서드는 양수 값에 대해 배열에서 가장 높은 순서의 바이트 비트가 0으로 설정된 바이트 배열을 반환하므로 양수 값을 음수로 잘못 해석할 가능성은 없습니다. 메서드에서 만든 ToByteArray 수정되지 않은 바이트 배열은 생성자에 전달될 BigInteger(Byte[]) 때 항상 성공적으로 왕복됩니다.

  • 메서드를 BitConverter.GetBytes 호출하고 매개 변수로 서명된 정수를 전달합니다. 부호 있는 정수는 부호 및 진도 표현과 두 개의 보수 표현을 모두 처리하므로 양수 값을 음수로 잘못 해석할 가능성은 없습니다.

  • 메서드를 BitConverter.GetBytes 호출하고 부호 없는 정수를 매개 변수로 전달합니다. 부호 없는 정수는 크기로만 표시되므로 양수 값은 음수 값으로 잘못 해석될 수 있습니다. 이러한 잘못된 해석을 방지하려면 배열의 끝에 0-바이트 값을 추가할 수 있습니다. 다음 섹션의 예제에서는 그림을 제공합니다.

  • 이전 메서드를 호출하지 않고 동적 또는 정적으로 바이트 배열을 만들거나 기존 바이트 배열을 수정합니다. 양수 값이 음수 값으로 잘못 해석되지 않도록 하려면 배열 끝에 0-바이트 값을 추가할 수 있습니다.

가 빈 Byte 배열이면 valueBigInteger 개체가 값BigInteger.Zero으로 초기화됩니다. 이 null이면 value 생성자는 을 ArgumentNullExceptionthrow합니다.

추가 정보

적용 대상

BigInteger(Decimal)

Source:
BigInteger.cs
Source:
BigInteger.cs
Source:
BigInteger.cs

BigInteger 값을 사용하여 Decimal 구조체의 새 인스턴스를 초기화합니다.

public:
 BigInteger(System::Decimal value);
public BigInteger (decimal value);
new System.Numerics.BigInteger : decimal -> System.Numerics.BigInteger
Public Sub New (value As Decimal)

매개 변수

value
Decimal

10진수입니다.

예제

다음 예제에서는 개체를 인스턴스화하는 데 생성자를 사용하는 BigInteger(Decimal) 방법을 BigInteger 보여 줍니다. 값 배열 Decimal 을 정의한 다음 각 값을 BigInteger(Decimal) 생성자에 전달합니다. 값이 개체에 Decimal 할당 BigInteger 될 때 반올림되는 대신 잘립니다.

decimal[] decimalValues = { -1790.533m, -15.1514m, 18903.79m, 9180098.003m };
foreach (decimal decimalValue in decimalValues)
{
   BigInteger number = new BigInteger(decimalValue);
   Console.WriteLine("Instantiated BigInteger value {0} from the Decimal value {1}.",
                     number, decimalValue);
}
// The example displays the following output:
//    Instantiated BigInteger value -1790 from the Decimal value -1790.533.
//    Instantiated BigInteger value -15 from the Decimal value -15.1514.
//    Instantiated BigInteger value 18903 from the Decimal value 18903.79.
//    Instantiated BigInteger value 9180098 from the Decimal value 9180098.003.
Dim decimalValues() As Decimal = { -1790.533d, -15.1514d, 18903.79d, 9180098.003d }
For Each decimalValue As Decimal In decimalValues
   Dim number As New BigInteger(decimalValue)
   Console.WriteLine("Instantiated BigInteger value {0} from the Decimal value {1}.",
                     number, decimalValue)
Next                 
' The example displays the following output:
'    Instantiated BigInteger value -1790 from the Decimal value -1790.533.
'    Instantiated BigInteger value -15 from the Decimal value -15.1514.
'    Instantiated BigInteger value 18903 from the Decimal value 18903.79.
'    Instantiated BigInteger value 9180098 from the Decimal value 9180098.003.

설명

이 생성자를 호출한 결과는 변수에 값을 BigInteger 명시적으로 할당하는 것과 Decimal 동일합니다.

이 생성자를 호출하면 데이터가 손실될 수 있습니다. 개체를 인스턴스화 BigInteger 할 때 의 value 소수 부분이 잘립니다.

적용 대상

BigInteger(Double)

Source:
BigInteger.cs
Source:
BigInteger.cs
Source:
BigInteger.cs

배정밀도 부동 소수점 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

public:
 BigInteger(double value);
public BigInteger (double value);
new System.Numerics.BigInteger : double -> System.Numerics.BigInteger
Public Sub New (value As Double)

매개 변수

value
Double

배정밀도 부동 소수점 값입니다.

예외

예제

다음 예제에서는 개체를 인스턴스화하는 데 생성자를 사용하는 BigInteger(Double) 방법을 BigInteger 보여 줍니다. 또한 데이터 형식을 사용할 Double 때 발생할 수 있는 정밀도 손실을 보여 줍니다. 에 Double 큰 값이 할당된 다음 개체에 BigInteger 할당됩니다. 출력에서 알 수 있듯이 이 할당에는 정밀도 손실이 포함됩니다. 그런 다음 두 값이 하나씩 증가합니다. 출력은 개체가 BigInteger 변경된 값을 반영하는 반면 개체는 반영하지 않음을 Double 보여 줍니다.

// Create a BigInteger from a large double value.
double doubleValue = -6e20;
BigInteger bigIntValue = new BigInteger(doubleValue);
Console.WriteLine("Original Double value: {0:N0}", doubleValue);
Console.WriteLine("Original BigInteger value: {0:N0}", bigIntValue);
// Increment and then display both values.
doubleValue++;
bigIntValue += BigInteger.One;
Console.WriteLine("Incremented Double value: {0:N0}", doubleValue);
Console.WriteLine("Incremented BigInteger value: {0:N0}", bigIntValue);
// The example displays the following output:
//    Original Double value: -600,000,000,000,000,000,000
//    Original BigInteger value: -600,000,000,000,000,000,000
//    Incremented Double value: -600,000,000,000,000,000,000
//    Incremented BigInteger value: -599,999,999,999,999,999,999
' Create a BigInteger from a large double value.
Dim doubleValue As Double = -6e20
Dim bigIntValue As New BigInteger(doubleValue)
Console.WriteLine("Original Double value: {0:N0}", doubleValue)
Console.WriteLine("Original BigInteger value: {0:N0}", bigIntValue)
' Increment and then display both values.
doubleValue += 1
bigIntValue += BigInteger.One
Console.WriteLine("Incremented Double value: {0:N0}", doubleValue)
Console.WriteLine("Incremented BigInteger value: {0:N0}", bigIntValue)
' The example displays the following output:
'    Original Double value: -600,000,000,000,000,000,000
'    Original BigInteger value: -600,000,000,000,000,000,000
'    Incremented Double value: -600,000,000,000,000,000,000
'    Incremented BigInteger value: -599,999,999,999,999,999,999

설명

개체를 인스턴스화 BigIntegervalue 때 매개 변수의 소수 부분이 잘립니다.

데이터 형식의 정밀도가 Double 부족하여 이 생성자를 호출하면 데이터가 손실될 수 있습니다.

BigInteger 생성자를 호출하여 발생하는 값은 에 값을 명시적으로 할당한 Double 결과 값 BigInteger과 동일합니다.

적용 대상

BigInteger(Int32)

Source:
BigInteger.cs
Source:
BigInteger.cs
Source:
BigInteger.cs

부호 있는 32비트 정수 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

public:
 BigInteger(int value);
public BigInteger (int value);
new System.Numerics.BigInteger : int -> System.Numerics.BigInteger
Public Sub New (value As Integer)

매개 변수

value
Int32

32비트 부호 있는 정수입니다.

예제

다음 예제에서는 생성자를 호출 BigInteger(Int32) 하여 32비트 정수 배열의 값을 인스턴스화 BigInteger 합니다. 또한 암시적 변환을 사용하여 각 32비트 정수 값을 변수에 BigInteger 할당합니다. 그런 다음 두 값을 비교하여 결과 BigInteger 값이 동일한지 확인합니다.

int[] integers = { Int32.MinValue, -10534, -189, 0, 17, 113439,
                   Int32.MaxValue };
BigInteger constructed, assigned;

foreach (int number in integers)
{
   constructed = new BigInteger(number);
   assigned = number;
   Console.WriteLine("{0} = {1}: {2}", constructed, assigned,
                     constructed.Equals(assigned));
}
// The example displays the following output:
//       -2147483648 = -2147483648: True
//       -10534 = -10534: True
//       -189 = -189: True
//       0 = 0: True
//       17 = 17: True
//       113439 = 113439: True
//       2147483647 = 2147483647: True
Dim integers() As Integer = { Int32.MinValue, -10534, -189, 0, 17, 113439,
                              Int32.MaxValue }
Dim constructed, assigned As BigInteger

For Each number As Integer In integers
   constructed = New BigInteger(number)
   assigned = number
   Console.WriteLine("{0} = {1}: {2}", constructed, assigned, 
                     constructed.Equals(assigned)) 
Next
' The example displays the following output:
'       -2147483648 = -2147483648: True
'       -10534 = -10534: True
'       -189 = -189: True
'       0 = 0: True
'       17 = 17: True
'       113439 = 113439: True
'       2147483647 = 2147483647: True

설명

이 생성자를 사용하여 개체를 인스턴스화할 BigInteger 때 정밀도는 손실되지 않습니다.

BigInteger 생성자를 호출하여 발생하는 값은 에 값을 할당한 결과 값과 Int32BigInteger동일합니다.

구조체에는 BigInteger , , Int16SByte또는 UInt16형식Byte의 매개 변수가 있는 생성자가 포함되지 않습니다. 그러나 형식은 Int32 부호 있는 8비트 및 16비트 부호 있는 정수와 부호 없는 정수를 부호 있는 32비트 정수로의 암시적 변환을 지원합니다. 결과적으로 이 생성자는 이 네 가지 정수 형식 중 하나인 경우 value 호출됩니다.

적용 대상

BigInteger(Int64)

Source:
BigInteger.cs
Source:
BigInteger.cs
Source:
BigInteger.cs

부호 있는 64비트 정수 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

public:
 BigInteger(long value);
public BigInteger (long value);
new System.Numerics.BigInteger : int64 -> System.Numerics.BigInteger
Public Sub New (value As Long)

매개 변수

value
Int64

64비트 부호 있는 정수입니다.

예제

다음 예제에서는 생성자를 호출 BigInteger(Int64) 하여 64비트 정수 배열에서 값을 인스턴스화 BigInteger 합니다. 또한 암시적 변환을 사용하여 각 64비트 정수 값을 변수에 BigInteger 할당합니다. 그런 다음 두 값을 비교하여 결과 BigInteger 값이 동일한지 확인합니다.

long[] longs = { Int64.MinValue, -10534, -189, 0, 17, 113439,
                 Int64.MaxValue };
BigInteger constructed, assigned;

foreach (long number in longs)
{
   constructed = new BigInteger(number);
   assigned = number;
   Console.WriteLine("{0} = {1}: {2}", constructed, assigned,
                     constructed.Equals(assigned));
}
// The example displays the following output:
//       -2147483648 = -2147483648: True
//       -10534 = -10534: True
//       -189 = -189: True
//       0 = 0: True
//       17 = 17: True
//       113439 = 113439: True
//       2147483647 = 2147483647: True
Dim longs() As Long = { Int64.MinValue, -10534, -189, 0, 17, 113439,
                              Int64.MaxValue }
Dim constructed, assigned As BigInteger

For Each number As Long In longs
   constructed = New BigInteger(number)
   assigned = number
   Console.WriteLine("{0} = {1}: {2}", constructed, assigned, 
                     constructed.Equals(assigned)) 
Next
' The example displays the following output:
'       -2147483648 = -2147483648: True
'       -10534 = -10534: True
'       -189 = -189: True
'       0 = 0: True
'       17 = 17: True
'       113439 = 113439: True
'       2147483647 = 2147483647: True

설명

이 생성자를 사용하여 개체를 인스턴스화할 BigInteger 때 정밀도는 손실되지 않습니다.

BigInteger 생성자를 호출하여 발생하는 값은 에 값을 할당한 결과 값과 Int64BigInteger동일합니다.

적용 대상

BigInteger(Single)

Source:
BigInteger.cs
Source:
BigInteger.cs
Source:
BigInteger.cs

단정밀도 부동 소수점 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

public:
 BigInteger(float value);
public BigInteger (float value);
new System.Numerics.BigInteger : single -> System.Numerics.BigInteger
Public Sub New (value As Single)

매개 변수

value
Single

단정밀도 부동 소수점 값입니다.

예외

예제

다음 예제에서는 개체를 인스턴스화하는 데 생성자를 사용하는 BigInteger(Single) 방법을 BigInteger 보여 줍니다. 또한 데이터 형식을 사용할 Single 때 발생할 수 있는 정밀도 손실을 보여 줍니다. Single 에는 큰 음수 값이 할당된 다음 개체에 BigInteger 할당됩니다. 출력에서 알 수 있듯이 이 할당에는 정밀도 손실이 포함됩니다. 그런 다음 두 값이 하나씩 증가합니다. 출력은 개체가 BigInteger 변경된 값을 반영하는 반면 개체는 반영하지 않음을 Single 보여 줍니다.

// Create a BigInteger from a large negative Single value
float negativeSingle = Single.MinValue;
BigInteger negativeNumber = new BigInteger(negativeSingle);

Console.WriteLine(negativeSingle.ToString("N0"));
Console.WriteLine(negativeNumber.ToString("N0"));

negativeSingle++;
negativeNumber++;

Console.WriteLine(negativeSingle.ToString("N0"));
Console.WriteLine(negativeNumber.ToString("N0"));
// The example displays the following output:
//       -340,282,300,000,000,000,000,000,000,000,000,000,000
//       -340,282,346,638,528,859,811,704,183,484,516,925,440
//       -340,282,300,000,000,000,000,000,000,000,000,000,000
//       -340,282,346,638,528,859,811,704,183,484,516,925,439
' Create a BigInteger from a large negative Single value
Dim negativeSingle As Single = Single.MinValue
Dim negativeNumber As New BigInteger(negativeSingle)

Console.WriteLine(negativeSingle.ToString("N0"))
Console.WriteLine(negativeNumber.ToString("N0"))

negativeSingle += 1
negativeNumber += 1
Console.WriteLine(negativeSingle.ToString("N0"))
Console.WriteLine(negativeNumber.ToString("N0"))
' The example displays the following output:
'       -340,282,300,000,000,000,000,000,000,000,000,000,000
'       -340,282,346,638,528,859,811,704,183,484,516,925,440
'       -340,282,300,000,000,000,000,000,000,000,000,000,000
'       -340,282,346,638,528,859,811,704,183,484,516,925,439

설명

개체를 인스턴스화 BigIntegervalue 때 매개 변수의 소수 부분이 잘립니다.

데이터 형식의 전체 자릿수가 Single 부족하기 때문에 이 생성자를 호출하면 데이터가 손실 될 수 있습니다.

BigInteger 생성자를 호출하여 발생하는 값은 에 값을 명시적으로 할당한 Single 결과 값과 BigInteger동일합니다.

적용 대상

BigInteger(UInt32)

Source:
BigInteger.cs
Source:
BigInteger.cs
Source:
BigInteger.cs

중요

이 API는 CLS 규격이 아닙니다.

CLS 대체 규격
System.Numerics.BigInteger.BigInteger(Int64)

부호 없는 32비트 정수 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

public:
 BigInteger(System::UInt32 value);
[System.CLSCompliant(false)]
public BigInteger (uint value);
[<System.CLSCompliant(false)>]
new System.Numerics.BigInteger : uint32 -> System.Numerics.BigInteger
Public Sub New (value As UInteger)

매개 변수

value
UInt32

부호 없는 32비트 정수 값입니다.

특성

예제

다음 예제에서는 생성자 및 assignment 문을 사용하여 BigInteger(UInt32) 부호 없는 32비트 정수 배열의 값을 초기화 BigInteger 합니다. 그런 다음 두 값을 비교하여 값을 초기화하는 BigInteger 두 메서드가 동일한 결과를 생성한다는 것을 보여 줍니다.

uint[] unsignedValues = { 0, 16704, 199365, UInt32.MaxValue };
foreach (uint unsignedValue in unsignedValues)
{
   BigInteger constructedNumber = new BigInteger(unsignedValue);
   BigInteger assignedNumber = unsignedValue;
   if (constructedNumber.Equals(assignedNumber))
      Console.WriteLine("Both methods create a BigInteger whose value is {0:N0}.",
                        constructedNumber);
   else
      Console.WriteLine("{0:N0} ≠ {1:N0}", constructedNumber, assignedNumber);
}
// The example displays the following output:
//    Both methods create a BigInteger whose value is 0.
//    Both methods create a BigInteger whose value is 16,704.
//    Both methods create a BigInteger whose value is 199,365.
//    Both methods create a BigInteger whose value is 4,294,967,295.
Dim unsignedValues() As UInteger = { 0, 16704, 199365, UInt32.MaxValue }
For Each unsignedValue As UInteger In unsignedValues
   Dim constructedNumber As New BigInteger(unsignedValue)
   Dim assignedNumber As BigInteger = unsignedValue
   If constructedNumber.Equals(assignedNumber) Then
      Console.WriteLine("Both methods create a BigInteger whose value is {0:N0}.",
                        constructedNumber)
   Else
      Console.WriteLine("{0:N0} ≠ {1:N0}", constructedNumber, assignedNumber)
   End If                         
Next
' The example displays the following output:
'    Both methods create a BigInteger whose value is 0.
'    Both methods create a BigInteger whose value is 16,704.
'    Both methods create a BigInteger whose value is 199,365.
'    Both methods create a BigInteger whose value is 4,294,967,295.

설명

이 생성자를 사용하여 를 인스턴스화할 BigInteger 때 정밀도는 손실되지 않습니다.

BigInteger 생성자를 호출하여 발생하는 값은 에 값을 할당한 결과 값과 UInt32BigInteger동일합니다.

적용 대상

BigInteger(UInt64)

Source:
BigInteger.cs
Source:
BigInteger.cs
Source:
BigInteger.cs

중요

이 API는 CLS 규격이 아닙니다.

CLS 대체 규격
System.Numerics.BigInteger.BigInteger(Double)

부호 없는 64비트 정수 값을 사용하여 BigInteger 구조체의 새 인스턴스를 초기화합니다.

public:
 BigInteger(System::UInt64 value);
[System.CLSCompliant(false)]
public BigInteger (ulong value);
[<System.CLSCompliant(false)>]
new System.Numerics.BigInteger : uint64 -> System.Numerics.BigInteger
Public Sub New (value As ULong)

매개 변수

value
UInt64

부호 없는 64비트 정수입니다.

특성

예제

다음 예제에서는 생성자를 사용하여 BigInteger(UInt64) 값이 와 같은 개체를 BigInteger 인스턴스화합니다 MaxValue.

ulong unsignedValue = UInt64.MaxValue;
BigInteger number = new BigInteger(unsignedValue);
Console.WriteLine(number.ToString("N0"));
// The example displays the following output:
//       18,446,744,073,709,551,615
Dim unsignedValue As ULong = UInt64.MaxValue
Dim number As New BigInteger(unsignedValue)
Console.WriteLine(number.ToString("N0"))       
' The example displays the following output:
'       18,446,744,073,709,551,615

설명

이 생성자를 사용하여 를 인스턴스화할 BigInteger 때 정밀도는 손실되지 않습니다.

BigInteger 생성자를 호출하여 발생하는 값은 에 값을 할당한 결과 값과 UInt64BigInteger동일합니다.

적용 대상

BigInteger(ReadOnlySpan<Byte>, Boolean, Boolean)

Source:
BigInteger.cs
Source:
BigInteger.cs
Source:
BigInteger.cs

읽기 전용 바이트 범위의 값을 사용하고 선택적으로 서명 인코딩 및 endian 바이트 순서를 나타내는 BigInteger 구조체의 새 인스턴스를 초기화합니다.

public BigInteger (ReadOnlySpan<byte> value, bool isUnsigned = false, bool isBigEndian = false);
new System.Numerics.BigInteger : ReadOnlySpan<byte> * bool * bool -> System.Numerics.BigInteger
Public Sub New (value As ReadOnlySpan(Of Byte), Optional isUnsigned As Boolean = false, Optional isBigEndian As Boolean = false)

매개 변수

value
ReadOnlySpan<Byte>

큰 정수를 나타내는 바이트의 읽기 전용 범위입니다.

isUnsigned
Boolean

value이 서명되지 않은 인코딩을 나타내면 true이고, 그렇지 않으면 false(기본값)입니다.

isBigEndian
Boolean

true 가 big-endian 바이트 순서임을 나타내 value 려면 이고, false 그렇지 않으면 (기본값)입니다.

적용 대상