C# 中的 BitConverter.DoubleToInt64Bits() 方法
C# 中的 BitConverter.DoubleToInt64Bits() 方法用于将指定双精度浮点数转换为 64 位有符号整数。
语法
以下是语法 −
public static long DoubleToInt64Bits (double val);
上述内容中,Val 是要转换的数字。
示例
现在让我们看一个示例来实现 BitConverter.DoubleToInt64Bits() 方法 −
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