Mega Code Archive

 
Categories / VB.Net / Data Types
 

Conversion of a Double to a BigInteger

Imports System.Numerics Imports System Module Example    Public Sub Main()         Dim doubles() As Double = { Double.MinValue, -1.430955172e03, 2.1111111111e05,                                      Double.MaxValue, Double.PositiveInfinity,                                      Double.NegativeInfinity, Double.NaN }         Dim number As BigInteger                  For Each value As Double In doubles            Try               number = CType(value, BigInteger)               Console.WriteLine("{0,37} {1,37}", value, number)            Catch e As OverflowException               Console.WriteLine("{0,37} {1,37}", value, "OverflowException")            End Try               Next     End Sub End Module