当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


C# BitConverter.Int64BitsToDouble()用法及代码示例


BitConverter.Int64BitsToDouble(Int64)方法用于将指定的64位带符号整数转换为双精度浮点数。

用法:

public static double Int64BitsToDouble (long value);

参数:此方法将64位带符号整数值作为参数。


返回值:此方法返回一个双精度浮点数,其值等于value。

以下示例程序旨在说明BitConverter.Int64BitsToDouble(Int64)方法的用法:

示例1:

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

double-precision floating point number: 1.06099789153011E-315

示例2:

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

double-precision floating point number: 4.94065645841247E-324

参考:



相关用法


注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 C# | BitConverter.Int64BitsToDouble() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。