C# BigInteger Explicit(BigInteger to Single)

Description

BigInteger Explicit(BigInteger to Single) Defines an explicit conversion of a BigInteger object to a single-precision floating-point value.

Syntax

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


public static explicit operator float (
  BigInteger value
)

Parameters

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

  • value - The value to convert to a single-precision floating-point value.

Returns

BigInteger.Explicit(BigInteger to Single) method returns An object that contains the closest possible representation of the value parameter.

Example


//from  w ww  .j  av a2s. c  o  m
using System;
using System.IO;
using System.Numerics;

public class Example
{
   public static void Main()
   {
        BigInteger number1 = (BigInteger) Single.MaxValue;
        BigInteger number2 = number1;
        number2 = number2 + (BigInteger) 9.999e30;
        Console.WriteLine("BigIntegers equal: {0}", number2.Equals(number1));
        
        float sng = (float) number2;
        
        Console.WriteLine("BigInteger: {0}", number2);
        Console.WriteLine("Single:     {0}", sng); 

        BigInteger goodSingle = (BigInteger) 122.43e22F;
        BigInteger badSingle = (BigInteger) float.MaxValue;  
        badSingle = badSingle * 2;
        
        float singleFromBigInteger;
        
        singleFromBigInteger = (float) goodSingle;
        Console.WriteLine(singleFromBigInteger);
        
        singleFromBigInteger = (float) badSingle;
        Console.WriteLine(singleFromBigInteger);
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Numerics »




BigInteger
Complex