Skip to content
Related Articles

Related Articles

C# | BitConverter.DoubleToInt64Bits() Method
  • Last Updated : 01 Feb, 2019

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

Syntax:

public static long DoubleToInt64Bits (double value);

Here, the value is the number which is to be converted.

Return Value: This method returns a 64-bit signed integer whose value is equivalent to value.

Below programs illustrate the use of BitConverter.DoubleToInt64Bits(Double) Method:



Example 1:




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

64-bit signed integer: 4608238818662570490

Example 2:




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

64-bit signed integer: 4607182418800017408

Hexadecimal value: 3FF0000000000000

Reference:

My Personal Notes arrow_drop_up
Recommended Articles
Page :