Complex.Explicit Complex.Explicit Complex.Explicit Complex.Explicit Operator

定義

オーバーロード

Explicit(Decimal to Complex) Explicit(Decimal to Complex) Explicit(Decimal to Complex) Explicit(Decimal to Complex)

Decimal 値から複素数への明示的な型変換を定義します。Defines an explicit conversion of a Decimal value to a complex number.

Explicit(BigInteger to Complex) Explicit(BigInteger to Complex) Explicit(BigInteger to Complex) Explicit(BigInteger to Complex)

BigInteger 値から複素数への明示的な型変換を定義します。Defines an explicit conversion of a BigInteger value to a complex number.

Explicit(Decimal to Complex) Explicit(Decimal to Complex) Explicit(Decimal to Complex) Explicit(Decimal to Complex)

Decimal 値から複素数への明示的な型変換を定義します。Defines an explicit conversion of a Decimal value to a complex number.

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

パラメーター

value
Decimal Decimal Decimal Decimal

複素数に変換する値。The value to convert to a complex number.

戻り値

実数部が value で、虚数部が 0 である複素数。A complex number that has a real component equal to value and an imaginary component equal to zero.

値を値に明示的にDecimal Complex変換する例を次に示します。The following example illustrates the explicit conversion of Decimal values to Complex values.

decimal[] numbers = { Decimal.MinValue, -18.35m, 0m, 1893.019m, 
                      Decimal.MaxValue };
foreach (decimal number in numbers)
{
   System.Numerics.Complex c1 = (System.Numerics.Complex) number;
   Console.WriteLine("{0,30}  -->  {1}", number, c1);
}   
// The example displays the following output:
//    -79228162514264337593543950335  -->  (-7.92281625142643E+28, 0)
//                            -18.35  -->  (-18.35, 0)
//                                 0  -->  (0, 0)
//                          1893.019  -->  (1893.019, 0)
//     79228162514264337593543950335  -->  (7.92281625142643E+28, 0)
Dim numbers() As Decimal = { Decimal.MinValue, -18.35d, 0d, 1893.019d, 
                             Decimal.MaxValue }
For Each number In numbers
   Dim c1 As System.Numerics.Complex = CType(number, 
                                             System.Numerics.Complex)
   Console.WriteLine("{0,30}  -->  {1}", number, c1)
Next   
' The example displays the following output:
'    -79228162514264337593543950335  -->  (-7.92281625142643E+28, 0)
'                            -18.35  -->  (-18.3500003814697, 0)
'                                 0  -->  (0, 0)
'                          1893.019  -->  (1893.01904296875, 0)
'     79228162514264337593543950335  -->  (7.92281625142643E+28, 0)

注釈

明示的な変換演算子は、 Complexオブジェクトに変換できる型を定義します。Explicit conversion operators define types that can be converted to a Complex object. 言語コンパイラでは、データが失われる可能性があるため、この変換は自動的には実行されません。Language compilers do not perform this conversion automatically because it can involve data loss. 代わりに、キャスト演算子 (でC#は) または変換関数 ( CType Visual Basic など) が使用されている場合にのみ、変換を実行します。Instead, they perform the conversion only if a casting operator (in C#) or a conversion function (such as CType in Visual Basic) is used. それ以外の場合は、コンパイラエラーが表示されます。Otherwise, they display a compiler error.

複素数の実数部Decimalに値を変換すると、精度が低下する可能性がありDecimalます。これはDouble、複素数のRealプロパティの型であるが、よりも有効桁数が少ないためです。The conversion of a Decimal value to the real part of a complex number can result in a loss of precision because a Double, which is the type of the complex number's Real property, has fewer significant digits than a Decimal.

Explicit(BigInteger to Complex) Explicit(BigInteger to Complex) Explicit(BigInteger to Complex) Explicit(BigInteger to Complex)

BigInteger 値から複素数への明示的な型変換を定義します。Defines an explicit conversion of a BigInteger value to a complex number.

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

パラメーター

value
BigInteger BigInteger BigInteger BigInteger

複素数に変換する値。The value to convert to a complex number.

戻り値

実数部が value で、虚数部が 0 である複素数。A complex number that has a real component equal to value and an imaginary component equal to zero.

値を値に明示的にBigInteger Complex変換する例を次に示します。The following example illustrates the explicit conversion of BigInteger values to Complex values.

BigInteger[] numbers= {
                 ((BigInteger) Double.MaxValue) * 2, 
                 BigInteger.Parse("901345277852317852466891423"), 
                 BigInteger.One }; 
foreach (BigInteger number in numbers)
{
  Complex c1 = (Complex) number;
   Console.WriteLine(c1);
}        
// The example displays the following output:
//       (Infinity, 0)
//       (9.01345277852318E+26, 0)
//       (1, 0)      
Dim numbers() As BigInteger = {
                 CType(Double.MaxValue, BigInteger) * 2, 
                 BigInteger.Parse("901345277852317852466891423"), 
                 BigInteger.One } 
For Each number In numbers
  Dim c1 As System.Numerics.Complex = CType(number, 
                                    System.Numerics.Complex)
   Console.WriteLine(c1)
Next        
' The example displays the following output:
'       (Infinity, 0)
'       (9.01345277852318E+26, 0)
'       (1, 0)      

注釈

明示的な変換演算子は、 Complexオブジェクトに変換できる型を定義します。Explicit conversion operators define types that can be converted to a Complex object. 言語コンパイラでは、データが失われる可能性があるため、この変換は自動的には実行されません。Language compilers do not perform this conversion automatically because it can involve data loss. 代わりに、キャスト演算子 (でC#は) または変換関数 ( CType Visual Basic など) が使用されている場合にのみ、変換を実行します。Instead, they perform the conversion only if a casting operator (in C#) or a conversion function (such as CType in Visual Basic) is used. それ以外の場合は、コンパイラエラーが表示されます。Otherwise, they display a compiler error.

複素数の実数部BigIntegerに値を変換すると、精度が低下する可能性がありBigIntegerます。これはDouble、複素数のRealプロパティの型であるが、よりも有効桁数が少ないためです。The conversion of a BigInteger value to the real part of a complex number can result in a loss of precision because a Double, which is the type of the complex number's Real property, has fewer significant digits than a BigInteger.

BigInteger値がDouble型の範囲外であるために変換が失敗した場合、操作はをOverflowExceptionスローしません。If the conversion is unsuccessful because the BigInteger value is out of the range of the Double type, the operation does not throw an OverflowException. 代わりに、がvalueよりMinValue小さい場合、結果はと等しいReal NegativeInfinityプロパティ値を持つ複素数になります。Instead, if value is less than MinValue, the result is a complex number that has a Real property value equal to NegativeInfinity. valueよりMaxValue大きい場合、結果はと等しいReal PositiveInfinityプロパティ値を持つ複素数になります。If value is greater than MaxValue, the result is a complex number that has a Real property value equal to PositiveInfinity.

適用対象