C# | BitConverter.Int64BitsToDouble() Method

BitConverter.Int64BitsToDouble(Int64) Method is used to convert the specified 64-bit signed integer to a double-precision floating point number.

Syntax:

public static double Int64BitsToDouble (long value);

Parameters: This method takes the 64-bit signed integer value as a parameter.

Return Value: This method returns a double-precision floating point number whose value is equivalent to value.

Below programs illustrate the use of BitConverter.Int64BitsToDouble(Int64) Method:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# program to demonstrate
// BitConverter.Int64BitsToDouble(Int64)
// Method
using System;
  
public class GFG {
  
    // Main Method
    public static void Main()
    {
  
        // declaring and initializing 
        // double value
        long value = 214748364;
  
        // Display the double value
        Console.Write("64-bit signed integer: ");
        Console.WriteLine("{0}", value);
        Console.WriteLine();
  
        // Converting double to long value
        // using BitConverter.DoubleToInt64Bits()
        // Method
        double value1 = BitConverter.Int64BitsToDouble(value);
  
        // Display the 64-bit signed integer.
        Console.Write("double-precision floating point number: ");
        Console.WriteLine("{0}", value1);
    }
}

chevron_right


Output:

64-bit signed integer: 214748364

double-precision floating point number: 1.06099789153011E-315

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# program to demonstrate
// BitConverter.Int64BitsToDouble(Int64)
// Method
using System;
using System.Collections.Generic;
  
public class GFG {
  
    // Main Method
    public static void Main()
    {
        // declaring and initializing
        // double value
        long value = 1;
  
        // Display the double value
        Console.Write("64-bit signed integer: ");
        Console.WriteLine("{0}", value);
        Console.WriteLine();
  
        // Converting double to long value
        // using BitConverter.DoubleToInt64Bits()
        // Method
        double value1 = BitConverter.Int64BitsToDouble(value);
  
        // Display the 64-bit signed integer.
        Console.Write("double-precision floating point number: ");
        Console.WriteLine("{0}", value1);
    }
}

chevron_right


Output:

64-bit signed integer: 1

double-precision floating point number: 4.94065645841247E-324

Reference:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.