當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。