C# BigInteger Explicit(Double to BigInteger)
Description
BigInteger Explicit(Double to BigInteger)
Defines
an explicit conversion of a Double value to a BigInteger value.
Syntax
BigInteger.Explicit(Double to BigInteger)
has the following syntax.
public static explicit operator BigInteger (
double value
)
Parameters
BigInteger.Explicit(Double to BigInteger)
has the following parameters.
value
- The value to convert to a BigInteger.
Returns
BigInteger.Explicit(Double to BigInteger)
method returns An object that contains the value of the value parameter.
Example
//from w w w. jav a 2 s . c o m
using System;
using System.IO;
using System.Numerics;
public class Example
{
public static void Main()
{
double[] doubles = { Double.MinValue, -1.430955172e03, 2.410970032e05,
Double.MaxValue, Double.PositiveInfinity,
Double.NegativeInfinity, Double.NaN };
BigInteger number;
Console.WriteLine("{0,37} {1,37}\n", "Double", "BigInteger");
foreach (double value in doubles)
{
try {
number = (BigInteger) value;
Console.WriteLine("{0,37} {1,37}", value, number);
}
catch (OverflowException) {
Console.WriteLine("{0,37} {1,37}", value, "OverflowException");
}
}
}
}
The code above generates the following result.