C# BigInteger Explicit(BigInteger to Double)

Description

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

Syntax

BigInteger.Explicit(BigInteger to Double) has the following syntax.


public static explicit operator double (
  BigInteger value
)

Parameters

BigInteger.Explicit(BigInteger to Double) has the following parameters.

  • value - The value to convert to a Double.

Returns

BigInteger.Explicit(BigInteger to Double) method returns An object that contains the value of the value parameter.

Example


/*from  w ww  . ja v a 2 s  .  c o m*/
using System;
using System.IO;
using System.Numerics;

public class Example
{
   public static void Main()
   {
        BigInteger number1 = (BigInteger) Double.MaxValue;
        BigInteger number2 = number1;
        number2 = number2 + (BigInteger) 9.999e291;
        Console.WriteLine("BigIntegers equal: {0}", number2.Equals(number1));
        
        double dbl = (double) number2;
        
        Console.WriteLine("BigInteger: {0}", number2);
        Console.WriteLine("Double:     {0}", dbl); 
        BigInteger goodDouble = (BigInteger) 102.43e22;
        BigInteger badDouble = (BigInteger) Double.MaxValue;  
        badDouble = badDouble * 2;
        
        double doubleFromBigInteger;
        
        // successful conversion using cast operator.
        doubleFromBigInteger = (double) goodDouble;
        Console.WriteLine(doubleFromBigInteger);
        
        // Convert an out-of-bounds BigInteger value to a Double.
        doubleFromBigInteger = (double) badDouble;
        Console.WriteLine(doubleFromBigInteger);
    
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Numerics »




BigInteger
Complex