BigInteger Explicit Conversion (BigInteger to Single)
Defines an explicit conversion of a BigInteger object to a single-precision floating-point value.
Assembly: System.Numerics (in System.Numerics.dll)
The value to convert to a single-precision floating-point value.
Return ValueType: System::Single
An object that contains the closest possible representation 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 or a loss of precision. Instead, they perform the conversion only if a casting operator (in C#) or a conversion function (such as CType or CSng in Visual Basic) is used. Otherwise, they display a compiler error.
Because the BigInteger value can be outside the range of the Single 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 Single::MinValue, the resulting Single value is Single::NegativeInfinity. If the BigInteger value is greater than Single::MaxValue, the resulting Single value is Single::PositiveInfinity.
The conversion of a BigInteger to a Single 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 Single data type. The following example provides an illustration. It assigns the maximum value of a Single 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 Single succeeds, although the BigInteger value now exceeds Single::MaxValue.
Available since 4.5
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Available since 4.0
Available since 8.1