This documentation is archived and is not being maintained.

BigInteger Explicit Conversion (Single to BigInteger)

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

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

public static explicit operator BigInteger (
	float value


Type: System.Single
The value to convert to a BigInteger.

Return Value

Type: System.Numerics.BigInteger
An object that contains the value of the value parameter.


value is Single.NaN.


value is Single.PositiveInfinity.


value is Single.NegativeInfinity.

Any fractional part of the value parameter is truncated before conversion.

The overloads of the Explicit(Decimal to BigInteger) method define the types to which or from which a BigInteger can be converted. Because the conversion from Single to BigInteger can involve truncating any fractional part of value, language compilers do not perform this conversion automatically. 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 following example converts the individual elements in an array of Single values to BigInteger objects, and then displays the result of each conversion. Note that any fractional part of a Single value is truncated during the conversion.

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      

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.