Reinterpret 64-bit signed integer to a double-precision floating point number in C#

CsharpServer Side ProgrammingProgramming

To reinterpret the specified 64-bit signed integer to a double-precision floating point number, the code is as follows −

Example

 Live Demo

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);
   }
}

Output

This will produce the following output −

Value (64-bit signed integer) = 9846587687
Value (double-precision floating point number) = 4.86486070491012E-314

Example

Let us see another example −

 Live Demo

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);
   }
}

Output

This will produce the following output −

Value (64-bit signed integer) = 20
Value (double-precision floating point number) = 9.88131291682493E-323
raja
Published on 11-Dec-2019 11:51:32
Advertisements