BigInteger Explicit Conversion (BigInteger to Double)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Defines an explicit conversion of a BigInteger object to a Double value.

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

public:
static explicit operator double (
	BigInteger value
)

Parameters

value
Type: System.Numerics::BigInteger

The value to convert to a Double.

Return Value

Type: System::Double

An object that contains the value of the value parameter.

The overloads of the Explicit(Decimal to BigInteger) method define the types to which or from which a BigInteger object can be converted. 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 or CDbl in Visual Basic) is used.

Because the BigInteger value can be outside the range of the Double data type, this operation is a narrowing conversion. If the conversion is unsuccessful, it does not throw an OverflowException. Instead, if the BigInteger value is less than Double::MinValue, the resulting Double value is Double::NegativeInfinity. If the BigInteger value is greater than Double::MaxValue, the resulting Double value is Double::PositiveInfinity.

The conversion of a BigInteger to a Double may involve a loss of precision. In some cases, the loss of precision may cause the casting or conversion operation to succeed even if the BigInteger value is outside the range of the Double data type. The following example provides an illustration. It assigns the maximum value of a Double to two BigInteger variables, increments one BigInteger variable by 9.999e291, and tests the two variables for equality. As expected, the call to the Equals(BigInteger) method shows that they are unequal. However, the conversion of the larger BigInteger value back to a Double succeeds, although the BigInteger value now exceeds Double::MaxValue.

No code example is currently available or this language may not be supported.

The following example illustrates the conversion of BigInteger to Double values.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0
Windows Phone
Available since 8.1
Return to top
Show: