BigInteger.Explicit 연산자

정의

BigInteger 개체와 다른 형식 간의 명시적 변환을 정의합니다.

오버로드

Explicit(BigInteger to SByte)

BigInteger 개체를 부호 있는 8비트 값으로 변환하는 명시적 변환을 정의합니다.

이 API는 CLS 규격이 아닙니다. 규격 대체 항목은 Int16입니다.

Explicit(Single to BigInteger)

Single 값을 BigInteger 값으로 변환하는 명시적 변환을 정의합니다.

Explicit(Complex to BigInteger)

값을 큰 정수로 명시적으로 변환합니다 Complex .

Explicit(BigInteger to UIntPtr)

큰 정수 를 값으로 UIntPtr 명시적으로 변환합니다.

Explicit(BigInteger to UInt64)

BigInteger 개체를 부호 없는 64비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

이 API는 CLS 규격이 아닙니다. 규격 대체 항목은 Double입니다.

Explicit(BigInteger to UInt32)

BigInteger 개체를 부호 없는 32비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

이 API는 CLS 규격이 아닙니다. 규격 대체 항목은 Int64입니다.

Explicit(BigInteger to UInt16)

BigInteger 개체를 부호 없는 16비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

이 API는 CLS 규격이 아닙니다. 규격 대체 항목은 Int32입니다.

Explicit(BigInteger to UInt128)

큰 정수 를 값으로 UInt128 명시적으로 변환합니다.

Explicit(BigInteger to Single)

BigInteger 개체를 단정밀도 부동 소수점 값으로 변환하는 명시적 변환을 정의합니다.

Explicit(BigInteger to IntPtr)

큰 정수 를 값으로 IntPtr 명시적으로 변환합니다.

Explicit(BigInteger to Int64)

BigInteger 개체를 부호 있는 64비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

Explicit(BigInteger to Int16)

BigInteger 개체를 부호 있는 16비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

Explicit(BigInteger to Int128)

큰 정수 를 값으로 Int128 명시적으로 변환합니다.

Explicit(BigInteger to Half)

큰 정수 를 값으로 Half 명시적으로 변환합니다.

Explicit(BigInteger to Double)

BigInteger 개체를 Double 값으로 변환하는 명시적 변환을 정의합니다.

Explicit(BigInteger to Decimal)

BigInteger 개체를 Decimal 값으로 변환하는 명시적 변환을 정의합니다.

Explicit(BigInteger to Char)

큰 정수 를 값으로 Char 명시적으로 변환합니다.

Explicit(BigInteger to Byte)

BigInteger 개체를 부호 없는 바이트 값으로 변환하는 명시적 변환을 정의합니다.

Explicit(Half to BigInteger)

값을 큰 정수로 명시적으로 변환합니다 Half .

Explicit(Double to BigInteger)

Double 값을 BigInteger 값으로 변환하는 명시적 변환을 정의합니다.

Explicit(Decimal to BigInteger)

Decimal 개체를 BigInteger 값으로 변환하는 명시적 변환을 정의합니다.

Explicit(BigInteger to Int32)

BigInteger 개체를 부호 있는 32비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

Explicit(BigInteger to SByte)

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

중요

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

CLS 대체 규격
System.Int16

BigInteger 개체를 부호 있는 8비트 값으로 변환하는 명시적 변환을 정의합니다.

이 API는 CLS 규격이 아닙니다. 규격 대체 항목은 Int16입니다.

public:
 static explicit operator System::SByte(System::Numerics::BigInteger value);
[System.CLSCompliant(false)]
public static explicit operator sbyte (System.Numerics.BigInteger value);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Numerics.BigInteger -> sbyte
Public Shared Narrowing Operator CType (value As BigInteger) As SByte

매개 변수

value
BigInteger

부호 있는 8비트 값으로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

특성

예외

value가 SByte.MinValue보다 작거나 SByte.MaxValue보다 큽습니다.

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 SByte 보여 줍니다. 또한 값이 데이터 형식의 범위를 벗어나기 때문에 BigInteger throw되는 를 SByte 처리 OverflowException 합니다.

// BigInteger to SByte conversion.
BigInteger goodSByte = BigInteger.MinusOne;
BigInteger badSByte = -130;

sbyte sByteFromBigInteger;

// Successful conversion using cast operator.
sByteFromBigInteger = (sbyte) goodSByte;
Console.WriteLine(sByteFromBigInteger);

// Handle conversion that should result in overflow.
try
{
   sByteFromBigInteger = (sbyte) badSByte;
   Console.WriteLine(sByteFromBigInteger);
}
catch (OverflowException e)
{
   Console.WriteLine("Unable to convert {0}:\n   {1}",
                     badSByte, e.Message);
}
Console.WriteLine();
' BigInteger to SByte conversion.
Dim goodSByte As BigInteger = BigInteger.MinusOne
Dim badSByte As BigInteger = -130

Dim sByteFromBigInteger As SByte

' Convert using CType function.
sByteFromBigInteger = CType(goodSByte, SByte)
Console.WriteLine(sByteFromBigInteger)
' Convert using CSByte function.
sByteFromBigInteger = CSByte(goodSByte)
Console.WriteLine(sByteFromBigInteger)

' Handle conversion that should result in overflow.
Try
   sByteFromBigInteger = CType(badSByte, SByte)
   Console.WriteLine(sByteFromBigInteger)
Catch e As OverflowException
   Console.WriteLine("Unable to convert {0}:{1}   {2}", _
                     badSByte, vbCrLf, e.Message)
End Try
Console.WriteLine()

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CSByte )를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

이 작업은 축소 변환을 정의하므로 값이 데이터 형식 범위를 벗어나면 런타임에 BigInteger 을 throw OverflowExceptionSByte 수 있습니다. 변환에 성공하면 결과 SByte 값의 전체 자릿수가 손실되지 않습니다.

적용 대상

Explicit(Single to BigInteger)

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

Single 값을 BigInteger 값으로 변환하는 명시적 변환을 정의합니다.

public:
 static explicit operator System::Numerics::BigInteger(float value);
public static explicit operator System.Numerics.BigInteger (float value);
static member op_Explicit : single -> System.Numerics.BigInteger
Public Shared Narrowing Operator CType (value As Single) As BigInteger

매개 변수

value
Single

BigInteger로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

예외

예제

다음 예제에서는 값 배열의 Single 개별 요소를 개체로 BigInteger 변환한 다음 각 변환의 결과를 표시합니다. 변환 중에 값의 Single 소수 부분이 잘립니다.

float[] singles = { Single.MinValue, -1.430955172e03f, 2.410970032e05f,
                    Single.MaxValue, Single.PositiveInfinity,
                     Single.NegativeInfinity, Single.NaN };
BigInteger number;

Console.WriteLine("{0,37} {1,37}\n", "Single", "BigInteger");

foreach (float value in singles)
{
   try {
      number = (BigInteger) value;
      Console.WriteLine("{0,37} {1,37}", value, number);
   }
   catch (OverflowException) {
      Console.WriteLine("{0,37} {1,37}", value, "OverflowException");
   }
}
// The example displays the following output:
//           Single                            BigInteger
//
//    -3.402823E+38   -3.4028234663852885981170418348E+38
//        -1430.955                                 -1430
//           241097                                241097
//     3.402823E+38    3.4028234663852885981170418348E+38
//         Infinity                     OverflowException
//        -Infinity                     OverflowException
//              NaN                     OverflowException
Dim singles() As Single = { Single.MinValue, -1.430955172e03, 2.410970032e05, 
                            Single.MaxValue, Single.PositiveInfinity, 
                            Single.NegativeInfinity, Single.NaN }
Dim number As BigInteger

Console.WriteLine("{0,37} {1,37}", "Single", "BigInteger")
Console.WriteLine()
For Each value As Single In singles
   Try
      number = CType(value, BigInteger)
      Console.WriteLine("{0,37} {1,37}", value, number)
   Catch e As OverflowException
      Console.WriteLine("{0,37} {1,37}", value, "OverflowException")
   End Try
Next     
' The example displays the following output:
'           Single                            BigInteger
' 
'    -3.402823E+38   -3.4028234663852885981170418348E+38
'        -1430.955                                 -1430
'           241097                                241097
'     3.402823E+38    3.4028234663852885981170418348E+38
'         Infinity                     OverflowException
'        -Infinity                     OverflowException
'              NaN                     OverflowException

설명

매개 변수의 value 소수 부분은 변환 전에 잘립니다.

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 에서 로 SingleBigInteger 의 변환은 의 value소수 부분을 잘림을 포함할 수 있으므로 언어 컴파일러가 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic)를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

사용자 지정 연산자를 지원하지 않는 언어의 경우 대체 방법은 입니다 BigInteger.BigInteger(Single).

적용 대상

Explicit(Complex to BigInteger)

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

값을 큰 정수로 명시적으로 변환합니다 Complex .

public:
 static explicit operator System::Numerics::BigInteger(System::Numerics::Complex value);
public static explicit operator System.Numerics.BigInteger (System.Numerics.Complex value);
static member op_Explicit : System.Numerics.Complex -> System.Numerics.BigInteger
Public Shared Narrowing Operator CType (value As Complex) As BigInteger

매개 변수

value
Complex

변환할 값입니다.

반환

value 을 큰 정수로 변환합니다.

적용 대상

Explicit(BigInteger to UIntPtr)

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

중요

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

큰 정수 를 값으로 UIntPtr 명시적으로 변환합니다.

public:
 static explicit operator UIntPtr(System::Numerics::BigInteger value);
[System.CLSCompliant(false)]
public static explicit operator UIntPtr (System.Numerics.BigInteger value);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Numerics.BigInteger -> unativeint
Public Shared Narrowing Operator CType (value As BigInteger) As UIntPtr

매개 변수

value
BigInteger

변환할 값입니다.

반환

UIntPtr

unativeint

value 값으로 UIntPtr 변환됩니다.

특성

적용 대상

Explicit(BigInteger to UInt64)

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

중요

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

CLS 대체 규격
System.Double

BigInteger 개체를 부호 없는 64비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

이 API는 CLS 규격이 아닙니다. 규격 대체 항목은 Double입니다.

public:
 static explicit operator System::UInt64(System::Numerics::BigInteger value);
[System.CLSCompliant(false)]
public static explicit operator ulong (System.Numerics.BigInteger value);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Numerics.BigInteger -> uint64
Public Shared Narrowing Operator CType (value As BigInteger) As ULong

매개 변수

value
BigInteger

부호 없는 64비트 정수로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

특성

예외

valueUInt64.MinValue보다 작거나 UInt64.MaxValue보다 큽다.

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 UInt64 보여 줍니다. 또한 값이 데이터 형식의 범위를 벗어나기 때문에 BigInteger throw되는 를 UInt64 처리 OverflowException 합니다.

// BigInteger to UInt64 conversion.
BigInteger goodULong = 2000000000;
BigInteger badULong = BigInteger.Pow(goodULong, 3);

ulong uLongFromBigInteger;

// Successful conversion using cast operator.
uLongFromBigInteger = (ulong) goodULong;
Console.WriteLine(uLongFromBigInteger);

// Handle conversion that should result in overflow.
try
{
   uLongFromBigInteger = (ulong) badULong;
   Console.WriteLine(uLongFromBigInteger);
}
catch (OverflowException e)
{
   Console.WriteLine("Unable to convert {0}:\n   {1}",
                     badULong, e.Message);
}
Console.WriteLine();
' BigInteger to UInt64 conversion.
Dim goodULong As BigInteger = 2000000000
Dim badULong As BigInteger = BigInteger.Pow(goodULong, 3)

Dim uLongFromBigInteger As ULong

' Convert using CType function.
uLongFromBigInteger = CType(goodULong, ULong)
Console.WriteLine(uLongFromBigInteger)
' Convert using CULng function.
uLongFromBigInteger = CULng(goodULong)
Console.WriteLine(uLongFromBigInteger)

' Handle conversion that should result in overflow.
Try
   uLongFromBigInteger = CType(badULong, ULong)
   Console.WriteLine(uLongFromBigInteger)
Catch e As OverflowException
   Console.WriteLine("Unable to convert {0}:{1}   {2}", _
                     badULong, vbCrLf, e.Message)
End Try
Console.WriteLine()

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CULng )를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

이 작업은 축소 변환을 정의하므로 값이 데이터 형식 범위를 벗어나면 런타임에 BigInteger 을 throw OverflowExceptionUInt64 수 있습니다. 변환에 성공하면 결과 UInt64 값의 전체 자릿수가 손실되지 않습니다.

적용 대상

Explicit(BigInteger to UInt32)

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

중요

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

CLS 대체 규격
System.Int64

BigInteger 개체를 부호 없는 32비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

이 API는 CLS 규격이 아닙니다. 규격 대체 항목은 Int64입니다.

public:
 static explicit operator System::UInt32(System::Numerics::BigInteger value);
[System.CLSCompliant(false)]
public static explicit operator uint (System.Numerics.BigInteger value);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Numerics.BigInteger -> uint32
Public Shared Narrowing Operator CType (value As BigInteger) As UInteger

매개 변수

value
BigInteger

부호 없는 32비트 정수로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

특성

예외

valueUInt32.MinValue 보다 작거나 UInt32.MaxValue보다 큽다.

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 UInt32 보여 줍니다. 또한 값이 데이터 형식의 범위를 벗어나기 때문에 BigInteger throw되는 를 UInt32 처리 OverflowException 합니다.

// BigInteger to UInt32 conversion.
BigInteger goodUInteger = 200000;
BigInteger badUInteger = 65000000000;

uint uIntegerFromBigInteger;

// Successful conversion using cast operator.
uIntegerFromBigInteger = (uint) goodInteger;
Console.WriteLine(uIntegerFromBigInteger);

// Handle conversion that should result in overflow.
try
{
   uIntegerFromBigInteger = (uint) badUInteger;
   Console.WriteLine(uIntegerFromBigInteger);
}
catch (OverflowException e)
{
   Console.WriteLine("Unable to convert {0}:\n   {1}",
                     badUInteger, e.Message);
}
Console.WriteLine();
' BigInteger to UInt32 conversion.
Dim goodUInteger As BigInteger = 200000
Dim badUInteger As BigInteger = 65000000000

Dim uIntegerFromBigInteger As UInteger

' Convert using CType function.
uIntegerFromBigInteger = CType(goodInteger, UInteger)
Console.WriteLine(uIntegerFromBigInteger)
' Convert using CUInt function.
uIntegerFromBigInteger = CUInt(goodInteger)
Console.WriteLine(uIntegerFromBigInteger)

' Handle conversion that should result in overflow.
Try
   uIntegerFromBigInteger = CType(badUInteger, UInteger)
   Console.WriteLine(uIntegerFromBigInteger)
Catch e As OverflowException
   Console.WriteLine("Unable to convert {0}:{1}   {2}", _
                     badUInteger, vbCrLf, e.Message)
End Try
Console.WriteLine()

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CUInt )를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

이 작업은 축소 변환을 정의하므로 값이 데이터 형식 범위를 벗어나면 런타임에 BigInteger 을 throw OverflowExceptionUInt32 수 있습니다. 변환에 성공하면 결과 UInt32 값의 전체 자릿수가 손실되지 않습니다.

적용 대상

Explicit(BigInteger to UInt16)

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

중요

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

CLS 대체 규격
System.Int32

BigInteger 개체를 부호 없는 16비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

이 API는 CLS 규격이 아닙니다. 규격 대체 항목은 Int32입니다.

public:
 static explicit operator System::UInt16(System::Numerics::BigInteger value);
[System.CLSCompliant(false)]
public static explicit operator ushort (System.Numerics.BigInteger value);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Numerics.BigInteger -> uint16
Public Shared Narrowing Operator CType (value As BigInteger) As UShort

매개 변수

value
BigInteger

부호 없는 16비트 정수로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

특성

예외

valueUInt16.MinValue보다 작거나 UInt16.MaxValue보다 큽다.

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 UInt16 보여 줍니다. 또한 값이 데이터 형식의 범위를 벗어나기 때문에 BigInteger throw되는 를 UInt16 처리 OverflowException 합니다.

// BigInteger to UInt16 conversion.
BigInteger goodUShort = 20000;
BigInteger badUShort = 66000;

ushort uShortFromBigInteger;

// Successful conversion using cast operator.
uShortFromBigInteger = (ushort) goodUShort;
Console.WriteLine(uShortFromBigInteger);

// Handle conversion that should result in overflow.
try
{
   uShortFromBigInteger = (ushort) badUShort;
   Console.WriteLine(uShortFromBigInteger);
}
catch (OverflowException e)
{
   Console.WriteLine("Unable to convert {0}:\n   {1}",
                     badUShort, e.Message);
}
Console.WriteLine();
' BigInteger to UInt16 conversion.
Dim goodUShort As BigInteger = 20000
Dim badUShort As BigInteger = 66000

Dim uShortFromBigInteger As UShort

' Convert using CType function.
uShortFromBigInteger = CType(goodUShort, UShort)
Console.WriteLine(uShortFromBigInteger)
' Convert using CUShort function.
uShortFromBigInteger = CUShort(goodUShort)
Console.WriteLine(uShortFromBigInteger)

' Handle conversion that should result in overflow.
Try
   uShortFromBigInteger = CType(badUShort, UShort)
   Console.WriteLine(uShortFromBigInteger)
Catch e As OverflowException
   Console.WriteLine("Unable to convert {0}:{1}   {2}", _
                     badUShort, vbCrLf, e.Message)
End Try
Console.WriteLine()

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CUShort )를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

이 작업은 축소 변환을 정의하므로 값이 데이터 형식 범위를 벗어나면 런타임에 BigInteger 을 throw OverflowExceptionUInt16 수 있습니다. 변환에 성공하면 결과 UInt16 값의 전체 자릿수가 손실되지 않습니다.

적용 대상

Explicit(BigInteger to UInt128)

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

중요

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

큰 정수 를 값으로 UInt128 명시적으로 변환합니다.

public:
 static explicit operator UInt128(System::Numerics::BigInteger value);
[System.CLSCompliant(false)]
public static explicit operator UInt128 (System.Numerics.BigInteger value);
[<System.CLSCompliant(false)>]
static member op_Explicit : System.Numerics.BigInteger -> UInt128
Public Shared Narrowing Operator CType (value As BigInteger) As UInt128

매개 변수

value
BigInteger

변환할 값입니다.

반환

value 값으로 UInt128 변환됩니다.

특성

적용 대상

Explicit(BigInteger to Single)

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

BigInteger 개체를 단정밀도 부동 소수점 값으로 변환하는 명시적 변환을 정의합니다.

public:
 static explicit operator float(System::Numerics::BigInteger value);
public static explicit operator float (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> single
Public Shared Narrowing Operator CType (value As BigInteger) As Single

매개 변수

value
BigInteger

단정밀도 부동 소수점 값으로 변환할 값입니다.

반환

value 매개 변수의 가능한 가장 가까운 표현을 포함하는 개체입니다.

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 Single 보여 줍니다.

// BigInteger to Single conversion.
BigInteger goodSingle = (BigInteger) 102.43e22F;
BigInteger badSingle = (BigInteger) float.MaxValue;
badSingle = badSingle * 2;

float singleFromBigInteger;

// Successful conversion using cast operator.
singleFromBigInteger = (float) goodSingle;
Console.WriteLine(singleFromBigInteger);

// Convert an out-of-bounds BigInteger value to a Single.
singleFromBigInteger = (float) badSingle;
Console.WriteLine(singleFromBigInteger);
' BigInteger to Single conversion.
Dim goodSingle As BigInteger = 102.43e22
Dim badSingle As BigInteger = CType(Single.MaxValue, BigInteger)  
badSingle = badSingle * 2

Dim singleFromBigInteger As Single

' Convert using CType function.
singleFromBigInteger = CType(goodSingle, Single)
Console.WriteLine(singleFromBigInteger)
' Convert using CSng function.
singleFromBigInteger = CSng(goodSingle)
Console.WriteLine(singleFromBigInteger)

' Convert an out-of-bounds BigInteger value to a Single.
singleFromBigInteger = CType(badSingle, Single)
Console.WriteLine(singleFromBigInteger)

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실 또는 정밀도 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CSng )를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

값이 BigInteger 데이터 형식의 Single 범위를 벗어날 수 있으므로 이 작업은 축소 변환입니다. 변환에 실패하면 을 OverflowExceptionthrow하지 않습니다. 대신 값이 BigInteger 보다 Single.MinValue작으면 결과 Single 값은 입니다 Single.NegativeInfinity. 값이 BigInteger 보다 Single.MaxValue크면 결과 Single 값은 입니다 Single.PositiveInfinity.

을 로 BigIntegerSingle 변환하면 정밀도 손실이 발생할 수 있습니다. 경우에 따라 값이 데이터 형식 범위를 벗어나 Single 더라도 BigInteger 전체 자릿수가 손실되면 캐스팅 또는 변환 작업이 성공할 수 있습니다. 다음 예제에서 이에 대해 설명합니다. 의 최대값을 SingleBigInteger 개의 변수에 할당하고, 한 BigInteger 변수를 9.999e291씩 증가시키고, 두 변수를 같음으로 테스트합니다. 예상대로 메서드를 호출하면 BigInteger.Equals(BigInteger) 같지 않음이 표시됩니다. 그러나 이제 값이 를 초과하더라도 더 큰 BigInteger 값을 로 Single 다시 변환하는 데 성공 BigInteger 합니다.Single.MaxValue

// Increase a BigInteger so it exceeds Single.MaxValue.
BigInteger number1 = (BigInteger) Single.MaxValue;
BigInteger number2 = number1;
number2 = number2 + (BigInteger) 9.999e30;
// Compare the BigInteger values for equality.
Console.WriteLine("BigIntegers equal: {0}", number2.Equals(number1));

// Convert the BigInteger to a Single.
float sng = (float) number2;

// Display the two values.
Console.WriteLine("BigInteger: {0}", number2);
Console.WriteLine("Single:     {0}", sng);
// The example displays the following output:
//       BigIntegers equal: False
//       BigInteger: 3.4028235663752885981170396038E+38
//       Single:     3.402823E+38
' Increase a BigInteger so it exceeds Single.MaxValue.
Dim number1 As BigInteger = CType(Single.MaxValue, BigInteger)
Dim number2 As BigInteger = number1
number2 = number2 + 9.999e30
' Compare the BigInteger values for equality.
Console.WriteLine("BigIntegers equal: {0}", number2.Equals(number1))

' Convert the BigInteger to a Single.
Dim sng As Single = CType(number2, Single)

' Display the two values.
Console.WriteLine("BigInteger: {0}", number2)
Console.WriteLine("Single:     {0}", sng)      
' The example displays the following output:
'       BigIntegers equal: False
'       BigInteger: 3.4028235663752885981170396038E+38
'       Single:     3.402823E+38

적용 대상

Explicit(BigInteger to IntPtr)

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

큰 정수 를 값으로 IntPtr 명시적으로 변환합니다.

public:
 static explicit operator IntPtr(System::Numerics::BigInteger value);
public static explicit operator IntPtr (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> nativeint
Public Shared Narrowing Operator CType (value As BigInteger) As IntPtr

매개 변수

value
BigInteger

변환할 값입니다.

반환

IntPtr

nativeint

value 값으로 IntPtr 변환됩니다.

적용 대상

Explicit(BigInteger to Int64)

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

BigInteger 개체를 부호 있는 64비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

public:
 static explicit operator long(System::Numerics::BigInteger value);
public static explicit operator long (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> int64
Public Shared Narrowing Operator CType (value As BigInteger) As Long

매개 변수

value
BigInteger

부호 있는 64비트 정수로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

예외

value가 Int64.MinValue보다 작거나 Int64.MaxValue보다 큽다.

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 Int64 보여 줍니다. 또한 값이 데이터 형식의 범위를 벗어나기 때문에 BigInteger throw되는 를 Int64 처리 OverflowException 합니다.

// BigInteger to Int64 conversion.
BigInteger goodLong = 2000000000;
BigInteger badLong = BigInteger.Pow(goodLong, 3);

long longFromBigInteger;

// Successful conversion using cast operator.
longFromBigInteger = (long) goodLong;
Console.WriteLine(longFromBigInteger);

// Handle conversion that should result in overflow.
try
{
   longFromBigInteger = (long) badLong;
   Console.WriteLine(longFromBigInteger);
}
catch (OverflowException e)
{
   Console.WriteLine("Unable to convert {0}:\n   {1}",
                     badLong, e.Message);
}
Console.WriteLine();
' BigInteger to Int64 conversion.
Dim goodLong As BigInteger = 2000000000
Dim badLong As BigInteger = BigInteger.Pow(goodLong, 3)

Dim longFromBigInteger As Long

' Convert using CType function.
longFromBigInteger = CType(goodLong, Long)
Console.WriteLine(longFromBigInteger)
' Convert using CLng function.
longFromBigInteger = CLng(goodLong)
Console.WriteLine(longFromBigInteger)

' Handle conversion that should result in overflow.
Try
   longFromBigInteger = CType(badLong, Long)
   Console.WriteLine(longFromBigInteger)
Catch e As OverflowException
   Console.WriteLine("Unable to convert {0}:{1}   {2}", _
                     badLong, vbCrLf, e.Message)
End Try
Console.WriteLine()

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CLng )를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

이 작업은 축소 변환을 정의하므로 값이 데이터 형식 범위를 벗어나면 런타임에 BigInteger 을 throw OverflowExceptionInt64 수 있습니다.

적용 대상

Explicit(BigInteger to Int16)

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

BigInteger 개체를 부호 있는 16비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

public:
 static explicit operator short(System::Numerics::BigInteger value);
public static explicit operator short (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> int16
Public Shared Narrowing Operator CType (value As BigInteger) As Short

매개 변수

value
BigInteger

부호 있는 16비트 정수로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

예외

valueInt16.MinValue보다 작거나 Int16.MaxValue보다 큽다.

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 Int16 보여 줍니다. 또한 값이 데이터 형식의 범위를 벗어나기 때문에 BigInteger throw되는 를 Int16 처리 OverflowException 합니다.

// BigInteger to Int16 conversion.
BigInteger goodShort = 20000;
BigInteger badShort = 33000;

short shortFromBigInteger;

// Successful conversion using cast operator.
shortFromBigInteger = (short) goodShort;
Console.WriteLine(shortFromBigInteger);

// Handle conversion that should result in overflow.
try
{
   shortFromBigInteger = (short) badShort;
   Console.WriteLine(shortFromBigInteger);
}
catch (OverflowException e)
{
   Console.WriteLine("Unable to convert {0}:\n   {1}",
                     badShort, e.Message);
}
Console.WriteLine();
' BigInteger to Int16 conversion.
Dim goodShort As BigInteger = 20000
Dim badShort As BigInteger = 33000

Dim shortFromBigInteger As Short

' Convert using CType function.
shortFromBigInteger = CType(goodShort, Short)
Console.WriteLine(shortFromBigInteger)
' Convert using CShort function.
shortFromBigInteger = CShort(goodShort)
Console.WriteLine(shortFromBigInteger)

' Handle conversion that should result in overflow.
Try
   shortFromBigInteger = CType(badShort, Short)
   Console.WriteLine(shortFromBigInteger)
Catch e As OverflowException
   Console.WriteLine("Unable to convert {0}:{1}   {2}", _
                     badShort, vbCrLf, e.Message)
End Try
Console.WriteLine()

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CShort )를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

이 작업은 축소 변환을 정의하므로 값이 데이터 형식 범위를 벗어나면 런타임에 BigInteger 을 throw OverflowExceptionInt16 수 있습니다. 변환에 성공하면 결과 Int16 값의 전체 자릿수가 손실되지 않습니다.

적용 대상

Explicit(BigInteger to Int128)

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

큰 정수 를 값으로 Int128 명시적으로 변환합니다.

public:
 static explicit operator Int128(System::Numerics::BigInteger value);
public static explicit operator Int128 (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> Int128
Public Shared Narrowing Operator CType (value As BigInteger) As Int128

매개 변수

value
BigInteger

변환할 값입니다.

반환

value 값으로 Int128 변환됩니다.

적용 대상

Explicit(BigInteger to Half)

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

큰 정수 를 값으로 Half 명시적으로 변환합니다.

public:
 static explicit operator Half(System::Numerics::BigInteger value);
public static explicit operator Half (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> Half
Public Shared Narrowing Operator CType (value As BigInteger) As Half

매개 변수

value
BigInteger

변환할 값입니다.

반환

value 값으로 Half 변환됩니다.

적용 대상

Explicit(BigInteger to Double)

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

BigInteger 개체를 Double 값으로 변환하는 명시적 변환을 정의합니다.

public:
 static explicit operator double(System::Numerics::BigInteger value);
public static explicit operator double (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> double
Public Shared Narrowing Operator CType (value As BigInteger) As Double

매개 변수

value
BigInteger

Double로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 Double 보여 줍니다.

// BigInteger to Double conversion.
BigInteger goodDouble = (BigInteger) 102.43e22;
BigInteger badDouble = (BigInteger) Double.MaxValue;
badDouble = badDouble * 2;

double doubleFromBigInteger;

// successful conversion using cast operator.
doubleFromBigInteger = (double) goodDouble;
Console.WriteLine(doubleFromBigInteger);

// Convert an out-of-bounds BigInteger value to a Double.
doubleFromBigInteger = (double) badDouble;
Console.WriteLine(doubleFromBigInteger);
' BigInteger to Double conversion.
Dim goodDouble As BigInteger = 102.43e22
Dim badDouble As BigInteger = CType(Double.MaxValue, BigInteger)  
badDouble = badDouble * 2

Dim doubleFromBigInteger As Double

' Convert using CType function.
doubleFromBigInteger = CType(goodDouble, Double)
Console.WriteLine(doubleFromBigInteger)
' Convert using CDbl function.
doubleFromBigInteger = CDbl(goodDouble)
Console.WriteLine(doubleFromBigInteger)

' Convert an out-of-bounds BigInteger value to a Double.
doubleFromBigInteger = CType(badDouble, Double)
Console.WriteLine(doubleFromBigInteger)

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CDbl )를 사용하는 경우에만 변환을 수행합니다.

값이 BigInteger 데이터 형식의 Double 범위를 벗어날 수 있으므로 이 작업은 축소 변환입니다. 변환에 실패하면 가 throw OverflowException되지 않습니다. 대신 값이 BigInteger 보다 Double.MinValue작으면 결과 Double 값은 입니다 Double.NegativeInfinity. 값이 BigInteger 보다 Double.MaxValue크면 결과 Double 값은 입니다 Double.PositiveInfinity.

을 로 BigInteger 변환하면 Double 정밀도 손실이 발생할 수 있습니다. 경우에 따라 값이 데이터 형식 범위를 벗어나 Double 더라도 BigInteger 정밀도 손실로 인해 캐스팅 또는 변환 작업이 성공할 수 있습니다. 다음 예제에서 이에 대해 설명합니다. 의 최대값을 DoubleBigInteger 개의 변수에 할당하고, 한 BigInteger 변수를 9.999e291씩 증가시키고, 두 변수가 같은지 테스트합니다. 예상대로 메서드에 대한 BigInteger.Equals(BigInteger) 호출은 같지 않음을 보여줍니다. 그러나 이제 값이 를 초과하더라도 Double 더 큰 BigInteger 값을 로 다시 변환하는 BigInteger 것은 성공합니다.Double.MaxValue

// Increase a BigInteger so it exceeds Double.MaxValue.
BigInteger number1 = (BigInteger) Double.MaxValue;
BigInteger number2 = number1;
number2 = number2 + (BigInteger) 9.999e291;
// Compare the BigInteger values for equality.
Console.WriteLine("BigIntegers equal: {0}", number2.Equals(number1));

// Convert the BigInteger to a Double.
double dbl = (double) number2;

// Display the two values.
Console.WriteLine("BigInteger: {0}", number2);
Console.WriteLine("Double:     {0}", dbl);
// The example displays the following output:
//       BigIntegers equal: False
//       BigInteger: 1.7976931348623158081352742373E+308
//       Double:     1.79769313486232E+308
' Increase a BigInteger so it exceeds Double.MaxValue.
Dim number1 As BigInteger = CType(Double.MaxValue, BigInteger)
Dim number2 As BigInteger = number1
number2 = number2 + 9.999e291
' Compare the BigInteger values for equality.
Console.WriteLine("BigIntegers equal: {0}", number2.Equals(number1))

' Convert the BigInteger to a Double.
Dim dbl As Double = CType(number2, Double)

' Display the two values.
Console.WriteLine("BigInteger: {0}", number2)
Console.WriteLine("Double:     {0}", dbl)      
' The example displays the following output:
'       BigIntegers equal: False
'       BigInteger: 1.7976931348623158081352742373E+308
'       Double:     1.79769313486232E+308

적용 대상

Explicit(BigInteger to Decimal)

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

BigInteger 개체를 Decimal 값으로 변환하는 명시적 변환을 정의합니다.

public:
 static explicit operator System::Decimal(System::Numerics::BigInteger value);
public static explicit operator decimal (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> decimal
Public Shared Narrowing Operator CType (value As BigInteger) As Decimal

매개 변수

value
BigInteger

Decimal로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

예외

valueDecimal.MinValue 보다 작거나 Decimal.MaxValue보다 큰 경우

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 Decimal 보여 줍니다. 또한 값이 데이터 형식의 범위를 벗어나기 때문에 BigInteger throw되는 를 Decimal 처리 OverflowException 합니다.

// BigInteger to Decimal conversion.
BigInteger goodDecimal = 761652543;
BigInteger badDecimal = (BigInteger) Decimal.MaxValue;
badDecimal += BigInteger.One;

Decimal decimalFromBigInteger;

// Successful conversion using cast operator.
decimalFromBigInteger = (decimal) goodDecimal;
Console.WriteLine(decimalFromBigInteger);

// Handle conversion that should result in overflow.
try
{
   decimalFromBigInteger = (decimal) badDecimal;
   Console.WriteLine(decimalFromBigInteger);
}
catch (OverflowException e)
{
   Console.WriteLine("Unable to convert {0}:\n   {1}",
                     badDecimal, e.Message);
}
Console.WriteLine();
' BigInteger to Decimal conversion.
Dim goodDecimal As BigInteger = 761652543
Dim badDecimal As BigInteger = CType(Decimal.MaxValue, BigInteger) 
badDecimal += BigInteger.One

Dim decimalFromBigInteger As Decimal

' Convert using CType function.
decimalFromBigInteger = CType(goodDecimal, Decimal)
Console.WriteLine(decimalFromBigInteger)
' Convert using CDec function.
decimalFromBigInteger = CDec(goodDecimal)
Console.WriteLine(decimalFromBigInteger)

' Handle conversion that should result in overflow.
Try
   decimalFromBigInteger = CType(badDecimal, Decimal)
   Console.WriteLine(decimalFromBigInteger)
Catch e As OverflowException
   Console.WriteLine("Unable to convert {0}:{1}   {2}", _
                     badDecimal, vbCrLf, e.Message)
End Try
Console.WriteLine()

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CDec )를 사용하는 경우에만 변환을 수행합니다.

이 작업은 축소 변환을 정의하므로 값이 데이터 형식 범위를 벗어나면 런타임에 BigInteger 을 throw OverflowExceptionDecimal 수 있습니다.

적용 대상

Explicit(BigInteger to Char)

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

큰 정 Char 수 를 값으로 명시적으로 변환합니다.

public:
 static explicit operator char(System::Numerics::BigInteger value);
public static explicit operator char (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> char
Public Shared Narrowing Operator CType (value As BigInteger) As Char

매개 변수

value
BigInteger

변환할 값입니다.

반환

value 값으로 Char 변환됩니다.

적용 대상

Explicit(BigInteger to Byte)

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

BigInteger 개체를 부호 없는 바이트 값으로 변환하는 명시적 변환을 정의합니다.

public:
 static explicit operator System::Byte(System::Numerics::BigInteger value);
public static explicit operator byte (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> byte
Public Shared Narrowing Operator CType (value As BigInteger) As Byte

매개 변수

value
BigInteger

Byte로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

예외

value가 Byte.MinValue보다 작거나 Byte.MaxValue보다 큰 경우

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 Byte 보여 줍니다. 또한 값이 데이터 형식의 범위를 벗어나기 때문에 BigInteger throw되는 를 Byte 처리 OverflowException 합니다.

// BigInteger to Byte conversion.
BigInteger goodByte = BigInteger.One;
BigInteger badByte = 256;

byte byteFromBigInteger;

// Successful conversion using cast operator.
byteFromBigInteger = (byte) goodByte;
Console.WriteLine(byteFromBigInteger);

// Handle conversion that should result in overflow.
try
{
   byteFromBigInteger = (byte) badByte;
   Console.WriteLine(byteFromBigInteger);
}
catch (OverflowException e)
{
   Console.WriteLine("Unable to convert {0}:\n   {1}",
                     badByte, e.Message);
}
Console.WriteLine();
' BigInteger to Byte conversion.
Dim goodByte As BigInteger = BigInteger.One
Dim badByte As BigInteger = 256

Dim byteFromBigInteger As Byte   

' Convert using CType function.
byteFromBigInteger = CType(goodByte, Byte)
Console.WriteLine(byteFromBigInteger)
' Convert using CByte function.
byteFromBigInteger = CByte(goodByte)
Console.WriteLine(byteFromBigInteger)

' Handle conversion that should result in overflow.
Try
   byteFromBigInteger = CType(badByte, Byte)
   Console.WriteLine(byteFromBigInteger)
Catch e As OverflowException
   Console.WriteLine("Unable to convert {0}:{1}   {2}", _
                     badByte, vbCrLf, e.Message)
End Try
Console.WriteLine()

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CByte )를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

이 작업은 축소 변환을 정의하므로 값이 데이터 형식 범위를 벗어나면 런타임에 BigInteger 을 throw OverflowExceptionByte 수 있습니다. 변환에 성공하면 결과 Byte 값에 정밀도 손실이 없습니다.

적용 대상

Explicit(Half to BigInteger)

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

값을 큰 정수로 Half 명시적으로 변환합니다.

public:
 static explicit operator System::Numerics::BigInteger(Half value);
public static explicit operator System.Numerics.BigInteger (Half value);
static member op_Explicit : Half -> System.Numerics.BigInteger
Public Shared Narrowing Operator CType (value As Half) As BigInteger

매개 변수

value
Half

변환할 값입니다.

반환

value 을 큰 정수로 변환합니다.

적용 대상

Explicit(Double to BigInteger)

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

Double 값을 BigInteger 값으로 변환하는 명시적 변환을 정의합니다.

public:
 static explicit operator System::Numerics::BigInteger(double value);
public static explicit operator System.Numerics.BigInteger (double value);
static member op_Explicit : double -> System.Numerics.BigInteger
Public Shared Narrowing Operator CType (value As Double) As BigInteger

매개 변수

value
Double

BigInteger로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

예외

예제

다음 예제에서는 값 배열의 Double 개별 요소를 개체로 BigInteger 변환한 다음 각 변환의 결과를 표시합니다. 변환하는 동안 값의 Double 소수 부분이 잘립니다.

double[] doubles = { Double.MinValue, -1.430955172e03, 2.410970032e05,
                     Double.MaxValue, Double.PositiveInfinity,
                     Double.NegativeInfinity, Double.NaN };
BigInteger number;

Console.WriteLine("{0,37} {1,37}\n", "Double", "BigInteger");

foreach (double value in doubles)
{
   try {
      number = (BigInteger) value;
      Console.WriteLine("{0,37} {1,37}", value, number);
   }
   catch (OverflowException) {
      Console.WriteLine("{0,37} {1,37}", value, "OverflowException");
   }
}
// The example displays the following output:
//                                Double                            BigInteger
//
//                -1.79769313486232E+308  -1.7976931348623157081452742373E+308
//                          -1430.955172                                 -1430
//                           241097.0032                                241097
//                 1.79769313486232E+308   1.7976931348623157081452742373E+308
//                              Infinity                     OverflowException
//                             -Infinity                     OverflowException
//                                   NaN                     OverflowException
Dim doubles() As Double = { Double.MinValue, -1.430955172e03, 2.410970032e05, 
                            Double.MaxValue, Double.PositiveInfinity, 
                            Double.NegativeInfinity, Double.NaN }
Dim number As BigInteger

Console.WriteLine("{0,37} {1,37}", "Double", "BigInteger")
Console.WriteLine()
For Each value As Double In doubles
   Try
      number = CType(value, BigInteger)
      Console.WriteLine("{0,37} {1,37}", value, number)
   Catch e As OverflowException
      Console.WriteLine("{0,37} {1,37}", value, "OverflowException")
   End Try      
Next
' The example displays the following output:
'                                Double                            BigInteger
' 
'                -1.79769313486232E+308  -1.7976931348623157081452742373E+308
'                          -1430.955172                                 -1430
'                           241097.0032                                241097
'                 1.79769313486232E+308   1.7976931348623157081452742373E+308
'                              Infinity                     OverflowException
'                             -Infinity                     OverflowException
'                                   NaN                     OverflowException

설명

매개 변수의 value 소수 부분은 변환 전에 잘립니다.

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 에서 로 DoubleBigInteger 의 변환에는 의 value일부분만 잘림이 포함될 수 있으므로 언어 컴파일러가 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic)를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

사용자 지정 연산자를 지원하지 않는 언어의 경우 대체 메서드는 입니다 BigInteger.BigInteger(Double).

적용 대상

Explicit(Decimal to BigInteger)

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

Decimal 개체를 BigInteger 값으로 변환하는 명시적 변환을 정의합니다.

public:
 static explicit operator System::Numerics::BigInteger(System::Decimal value);
public static explicit operator System.Numerics.BigInteger (decimal value);
static member op_Explicit : decimal -> System.Numerics.BigInteger
Public Shared Narrowing Operator CType (value As Decimal) As BigInteger

매개 변수

value
Decimal

BigInteger로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

예제

다음 예제에서는 값 배열의 Decimal 개별 요소를 개체로 BigInteger 변환한 다음 각 변환의 결과를 표시합니다. 변환하는 동안 값의 Decimal 소수 부분이 잘립니다.

decimal[] decimals = { Decimal.MinValue, -15632.991m, 9029321.12m,
                       Decimal.MaxValue };
BigInteger number;

Console.WriteLine("{0,35} {1,35}\n", "Decimal", "BigInteger");

foreach (decimal value in decimals)
{
   number = (BigInteger) value;
   Console.WriteLine("{0,35} {1,35}", value, number);
}
// The example displays the following output:
//
//                          Decimal                          BigInteger
//
//    -79228162514264337593543950335      -79228162514264337593543950335
//                       -15632.991                              -15632
//                       9029321.12                             9029321
//    79228162514264337593543950335       79228162514264337593543950335
' Explicit Decimal to BigInteger conversion
Dim decimals() As Decimal = { Decimal.MinValue, -15632.991d, 9029321.12d, 
                              Decimal.MaxValue }
Dim number As BigInteger 

Console.WriteLine("{0,35} {1,35}", "Decimal", "BigInteger")
Console.WriteLine()
For Each value As Decimal In decimals
   number = CType(value, BigInteger)
   Console.WriteLine("{0,35} {1,35}",
                     value, number)
Next
' The example displays the following output:
'
'                          Decimal                          BigInteger
'    
'    -79228162514264337593543950335      -79228162514264337593543950335
'                       -15632.991                              -15632
'                       9029321.12                             9029321
'    79228162514264337593543950335       79228162514264337593543950335

설명

매개 변수의 value 소수 부분은 변환 전에 잘립니다.

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 에서 로 DecimalBigInteger 의 변환에는 의 value일부분만 잘림이 포함될 수 있으므로 언어 컴파일러가 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic)를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

사용자 지정 연산자를 지원하지 않는 언어의 경우 대체 메서드는 입니다 BigInteger.BigInteger(Decimal).

적용 대상

Explicit(BigInteger to Int32)

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

BigInteger 개체를 부호 있는 32비트 정수 값으로 변환하는 명시적 변환을 정의합니다.

public:
 static explicit operator int(System::Numerics::BigInteger value);
public static explicit operator int (System.Numerics.BigInteger value);
static member op_Explicit : System.Numerics.BigInteger -> int
Public Shared Narrowing Operator CType (value As BigInteger) As Integer

매개 변수

value
BigInteger

부호 있는 32비트 정수로 변환할 값입니다.

반환

value 매개 변수의 값이 들어 있는 개체입니다.

예외

value가 Int32.MinValue보다 작거나 Int32.MaxValue보다 큽

예제

다음 예제에서는 값을 변환 BigInteger 하는 방법을 Int32 보여 줍니다. 또한 값이 데이터 형식의 범위를 벗어나기 때문에 BigInteger throw되는 를 Int32 처리 OverflowException 합니다.

// BigInteger to Int32 conversion.
BigInteger goodInteger = 200000;
BigInteger badInteger = 65000000000;

int integerFromBigInteger;

// Successful conversion using cast operator.
integerFromBigInteger = (int) goodInteger;
Console.WriteLine(integerFromBigInteger);

// Handle conversion that should result in overflow.
try
{
   integerFromBigInteger = (int) badInteger;
   Console.WriteLine(integerFromBigInteger);
}
catch (OverflowException e)
{
   Console.WriteLine("Unable to convert {0}:\n   {1}",
                     badInteger, e.Message);
}
Console.WriteLine();
' BigInteger to Int32 conversion.
Dim goodInteger As BigInteger = 200000
Dim badInteger As BigInteger = 65000000000

Dim integerFromBigInteger As Integer

' Convert using CType function.
integerFromBigInteger = CType(goodInteger, Integer)
Console.WriteLine(integerFromBigInteger)
' Convert using CInt function.
integerFromBigInteger = CInt(goodInteger)
Console.WriteLIne(integerFromBigInteger)

' Handle conversion that should result in overflow.
Try
   integerFromBigInteger = CType(badInteger, Integer)
   Console.WriteLine(integerFromBigInteger)
Catch e As OverflowException
   Console.WriteLine("Unable to convert {0}:{1}   {2}", _
                     badInteger, vbCrLf, e.Message)
End Try
Console.WriteLine()

설명

메서드의 Explicit(Decimal to BigInteger) 오버로드는 개체를 변환할 수 있는 BigInteger 형식을 정의합니다. 언어 컴파일러에서는 데이터 손실이 포함될 수 있으므로 이 변환을 자동으로 수행하지 않습니다. 대신 캐스팅 연산자(C#) 또는 변환 함수(예: CType Visual Basic의 또는 CInt )를 사용하는 경우에만 변환을 수행합니다. 그렇지 않으면 컴파일러 오류가 표시됩니다.

이 작업은 축소 변환을 정의하므로 값이 데이터 형식 범위를 벗어나면 런타임에 BigInteger 을 throw OverflowExceptionInt32 수 있습니다. 변환에 성공하면 결과 Int32 값에 정밀도 손실이 없습니다.

적용 대상