將指定雙精度浮點數轉換為 C# 中的 64 位有符號整數
要把指定雙精度浮點數轉換為 64 位有符號整數,程式碼如下 -
例項
using System;
public class Demo {
public static void Main() {
double d = 5.646587687;
Console.Write("Value = "+d);
long res = BitConverter.DoubleToInt64Bits(d);
Console.Write("
64-bit signed integer = "+res);
}
}輸出
將輸出以下內容 -
Value = 5.646587687 64-bit signed integer = 4618043510978159912
例項
讓我們看另一個示例 -
using System;
public class Demo {
public static void Main() {
double d = 0.001;
Console.Write("Value = "+d);
long res = BitConverter.DoubleToInt64Bits(d);
Console.Write("
64-bit signed integer = "+res);
}
}輸出
將輸出以下內容 -
Value = 0.001 64-bit signed integer = 4562254508917369340
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP