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:
using System;
public class GFG {
public static void Main()
{
double value = 1.2345678901234565;
Console.Write( "double-precision floating point: " );
Console.WriteLine( "{0}" , value);
Console.WriteLine();
long value1 = BitConverter.DoubleToInt64Bits(value);
Console.Write( "64-bit signed integer: " );
Console.WriteLine( "{0}" , value1);
}
}
|
Output:
double-precision floating point: 1.23456789012346
64-bit signed integer: 4608238818662570490
Example 2:
using System;
class GFG {
public static void Main()
{
double value = 1.0;
Console.Write( "double-precision floating point: " );
Console.WriteLine( "{0}" , value);
Console.WriteLine();
long value1 = BitConverter.DoubleToInt64Bits(value);
Console.Write( "64-bit signed integer: " );
Console.WriteLine( "{0}" , value1);
Console.WriteLine();
Console.Write( "Hexadecimal value: " );
Console.WriteLine(value1.ToString( "X" ));
}
}
|
Output:
double-precision floating point: 1
64-bit signed integer: 4607182418800017408
Hexadecimal value: 3FF0000000000000
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...