Int64 - Int64BitsToDouble
Converts the specified 64-bit signed integer to a double-precision floating point number.
const string formatter = "{0,20}{1,27:E16}"; public static void LongBitsToDouble(long argument) { //C# Extension Method: Int64 - Int64BitsToDouble double doubleValue = argument.Int64BitsToDouble(); Console.WriteLine(formatter, String.Format("0x{0:X16}", argument), doubleValue); } public static void Main() { Console.WriteLine(formatter, "long argument", "double value"); Console.WriteLine(formatter, "-------------", "------------"); LongBitsToDouble(0); LongBitsToDouble(0x3FF0000000000000); LongBitsToDouble(0x402E000000000000); LongBitsToDouble(0x406FE00000000000); LongBitsToDouble(0x41EFFFFFFFE00000); LongBitsToDouble(0x3F70000000000000); LongBitsToDouble(0x3DF0000000000000); LongBitsToDouble(0x0000000000000001); LongBitsToDouble(0x000000000000FFFF); LongBitsToDouble(0x0000FFFFFFFFFFFF); LongBitsToDouble(unchecked((long)0xFFFFFFFFFFFFFFFF)); LongBitsToDouble(unchecked((long)0xFFF0000000000000)); LongBitsToDouble(0x7FF0000000000000); LongBitsToDouble(unchecked((long)0xFFEFFFFFFFFFFFFF)); LongBitsToDouble(0x7FEFFFFFFFFFFFFF); LongBitsToDouble(long.MinValue); LongBitsToDouble(long.MaxValue); }
View Source
using System; public static partial class Extensions { /// <summary> /// Converts the specified 64-bit signed integer to a double-precision floating point number. /// </summary> /// <param name="value">The number to convert.</param> /// <returns>A double-precision floating point number whose value is equivalent to .</returns> public static Double Int64BitsToDouble(this Int64 value) { return BitConverter.Int64BitsToDouble(value); } }