Phương thức BitConverter.Int64BitsToDouble() trong C# diễn giải lại số nguyên có dấu 64-bit được chỉ định thành số thực dấu phẩy động độ chính xác kép.
Cú pháp
public static double Int64BitsToDouble(long val);
Tham số val là số cần chuyển đổi.
Ví dụ 1
using System;
public class Demo
{
public static void Main()
{
long d = 9846587687;
Console.Write("Value (64-bit signed integer) = " + d);
double res = BitConverter.Int64BitsToDouble(d);
Console.Write("\nValue (double-precision floating point number) = " + res);
}
}
Đầu ra
Value (64-bit signed integer) = 9846587687 Value (double-precision floating point number) = 4.86486070491012E-314
Ví dụ 2
using System;
public class Demo
{
public static void Main()
{
long d = 20;
Console.Write("Value (64-bit signed integer) = " + d);
double res = BitConverter.Int64BitsToDouble(d);
Console.Write("\nValue (double-precision floating point number) = " + res);
}
}
Đầu ra
Value (64-bit signed integer) = 20 Value (double-precision floating point number) = 9.88131291682493E-323