本文整理汇总了C#中System.BitConverter.Int64BitsToDouble方法的典型用法代码示例。如果您正苦于以下问题:C# BitConverter.Int64BitsToDouble方法的具体用法?C# BitConverter.Int64BitsToDouble怎么用?C# BitConverter.Int64BitsToDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.BitConverter
的用法示例。
在下文中一共展示了BitConverter.Int64BitsToDouble方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LongBitsToDouble
// Example of the BitConverter.Int64BitsToDouble method.
using System;
class Int64BitsToDoubleDemo
{
const string formatter = "{0,20}{1,27:E16}";
// Reinterpret the long argument as a double.
public static void LongBitsToDouble( long argument )
{
double doubleValue;
doubleValue = BitConverter.Int64BitsToDouble( argument );
// Display the argument in hexadecimal.
Console.WriteLine( formatter,
String.Format( "0x{0:X16}", argument ), doubleValue );
}
public static void Main( )
{
Console.WriteLine(
"This example of the BitConverter.Int64BitsToDouble( " +
"long ) \nmethod generates the following output.\n" );
Console.WriteLine( formatter, "long argument",
"double value" );
Console.WriteLine( formatter, "-------------",
"------------" );
// Convert long values and display the results.
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 );
}
}
输出:
long argument double value ------------- ------------ 0x0000000000000000 0.0000000000000000E+000 0x3FF0000000000000 1.0000000000000000E+000 0x402E000000000000 1.5000000000000000E+001 0x406FE00000000000 2.5500000000000000E+002 0x41EFFFFFFFE00000 4.2949672950000000E+009 0x3F70000000000000 3.9062500000000000E-003 0x3DF0000000000000 2.3283064365386963E-010 0x0000000000000001 4.9406564584124654E-324 0x000000000000FFFF 3.2378592100206092E-319 0x0000FFFFFFFFFFFF 1.3906711615669959E-309 0xFFFFFFFFFFFFFFFF NaN 0xFFF0000000000000 -Infinity 0x7FF0000000000000 Infinity 0xFFEFFFFFFFFFFFFF -1.7976931348623157E+308 0x7FEFFFFFFFFFFFFF 1.7976931348623157E+308 0x8000000000000000 0.0000000000000000E+000 0x7FFFFFFFFFFFFFFF NaN