Complex Explicit Conversion (BigInteger to Complex)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Defines an explicit conversion of a BigInteger value to a complex number.

Namespace:  System.Numerics
Assembly:  System.Numerics (in System.Numerics.dll)

Syntax

'Declaration
Public Shared Narrowing Operator CType ( _
    value As BigInteger _
) As Complex
public static explicit operator Complex (
    BigInteger value
)

Parameters

Return Value

Type: System.Numerics.Complex
A complex number that has a real component equal to value and an imaginary component equal to zero.

Remarks

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. 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.

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.

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. Instead, if value is less than Double.MinValue, the result is a complex number that has a Real property value equal to Double.NegativeInfinity. If value is greater than Double.MaxValue, the result is a complex number that has a Real property value equal to Double.PositiveInfinity.

Examples

The following example illustrates the explicit conversion of BigInteger values to Complex values.

Dim numbers() As BigInteger = {
                 CType(Double.MaxValue, BigInteger) * 2,
                 CType(UInt64.MaxValue, BigInteger) + UInt32.MaxValue,  
                 BigInteger.One } 
For Each number In numbers
  Dim c1 As System.Numerics.Complex = CType(number, 
                                    System.Numerics.Complex)
   outputBlock.Text &= c1.ToString() & vbCrLf
Next
' The example displays the following output:
'       (Infinity, 0)
'       (9.01345277852318E+26, 0)
'       (1, 0)      
BigInteger[] numbers = {
                 ((BigInteger) Double.MaxValue) * 2, 
                 ((BigInteger) UInt64.MaxValue) + UInt32.MaxValue, 
                 BigInteger.One };
foreach (BigInteger number in numbers)
{
   Complex c1 = (Complex)number;
   outputBlock.Text += c1 + "\n";
}
// The example displays the following output:
//       (Infinity, 0)
//       (9.01345277852318E+26, 0)
//       (1, 0)      

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.