다음을 통해 공유


BitConverter.DoubleToInt64Bits(Double) 메서드

정의

지정된 배정밀도 부동 소수점 숫자를 64비트 부호 있는 정수로 변환합니다.

public:
 static long DoubleToInt64Bits(double value);
public static long DoubleToInt64Bits (double value);
static member DoubleToInt64Bits : double -> int64
Public Shared Function DoubleToInt64Bits (value As Double) As Long

매개 변수

value
Double

변환할 숫자입니다.

반환

value의 값에 해당하는 64비트 부호 있는 정수입니다.

예제

다음 코드 예제에서는 여러 Double 값의 비트 패턴을 메서드를 사용하여 Int64 값으로 DoubleToInt64Bits 변환합니다.

// Example of the BitConverter::DoubleToInt64Bits method.
using namespace System;

// Reinterpret the double argument as an __int64.
void DoubleToLongBits( double argument )
{
   __int64 longValue;
   longValue = BitConverter::DoubleToInt64Bits( argument );
   
   // Display the resulting __int64 in hexadecimal.
   Console::WriteLine( "{0,25:E16}{1,23:X16}", argument, longValue );
}

int main()
{
   Console::WriteLine( "This example of the BitConverter::DoubleToInt64Bits( "
   "double ) \nmethod generates the following output.\n" );
   Console::WriteLine( "{0,25:E16}{1,23:X16}", "double argument", "hexadecimal value" );
   Console::WriteLine( "{0,25:E16}{1,23:X16}", "---------------", "-----------------" );
   
   // Convert double values and display the results.
   DoubleToLongBits( 1.0 );
   DoubleToLongBits( 15.0 );
   DoubleToLongBits( 255.0 );
   DoubleToLongBits( 4294967295.0 );
   DoubleToLongBits( 0.00390625 );
   DoubleToLongBits( 0.00000000023283064365386962890625 );
   DoubleToLongBits( 1.234567890123E-300 );
   DoubleToLongBits( 1.23456789012345E-150 );
   DoubleToLongBits( 1.2345678901234565 );
   DoubleToLongBits( 1.2345678901234567 );
   DoubleToLongBits( 1.2345678901234569 );
   DoubleToLongBits( 1.23456789012345678E+150 );
   DoubleToLongBits( 1.234567890123456789E+300 );
   DoubleToLongBits( Double::MinValue );
   DoubleToLongBits( Double::MaxValue );
   DoubleToLongBits( Double::Epsilon );
   DoubleToLongBits( Double::NaN );
   DoubleToLongBits( Double::NegativeInfinity );
   DoubleToLongBits( Double::PositiveInfinity );
}

/*
This example of the BitConverter::DoubleToInt64Bits( double )
method generates the following output.

          double argument      hexadecimal value
          ---------------      -----------------
  1.0000000000000000E+000       3FF0000000000000
  1.5000000000000000E+001       402E000000000000
  2.5500000000000000E+002       406FE00000000000
  4.2949672950000000E+009       41EFFFFFFFE00000
  3.9062500000000000E-003       3F70000000000000
  2.3283064365386963E-010       3DF0000000000000
  1.2345678901230000E-300       01AA74FE1C1E7E45
  1.2345678901234500E-150       20D02A36586DB4BB
  1.2345678901234565E+000       3FF3C0CA428C59FA
  1.2345678901234567E+000       3FF3C0CA428C59FB
  1.2345678901234569E+000       3FF3C0CA428C59FC
  1.2345678901234569E+150       5F182344CD3CDF9F
  1.2345678901234569E+300       7E3D7EE8BCBBD352
 -1.7976931348623157E+308       FFEFFFFFFFFFFFFF
  1.7976931348623157E+308       7FEFFFFFFFFFFFFF
  4.9406564584124654E-324       0000000000000001
                      NaN       FFF8000000000000
                -Infinity       FFF0000000000000
                 Infinity       7FF0000000000000
*/
// Example of the BitConverter.DoubleToInt64Bits method.
using System;

class DoubleToInt64BitsDemo
{
    const string formatter = "{0,25:E16}{1,23:X16}";

    // Reinterpret the double argument as a long.
    public static void DoubleToLongBits( double argument )
    {
        long longValue;
        longValue = BitConverter.DoubleToInt64Bits( argument );

        // Display the resulting long in hexadecimal.
        Console.WriteLine( formatter, argument, longValue );
    }

    public static void Main( )
    {
        Console.WriteLine(
            "This example of the BitConverter.DoubleToInt64Bits( " +
            "double ) \nmethod generates the following output.\n" );
        Console.WriteLine( formatter, "double argument",
            "hexadecimal value" );
        Console.WriteLine( formatter, "---------------",
            "-----------------" );

        // Convert double values and display the results.
        DoubleToLongBits( 1.0 );
        DoubleToLongBits( 15.0 );
        DoubleToLongBits( 255.0 );
        DoubleToLongBits( 4294967295.0 );
        DoubleToLongBits( 0.00390625 );
        DoubleToLongBits( 0.00000000023283064365386962890625 );
        DoubleToLongBits( 1.234567890123E-300 );
        DoubleToLongBits( 1.23456789012345E-150 );
        DoubleToLongBits( 1.2345678901234565 );
        DoubleToLongBits( 1.2345678901234567 );
        DoubleToLongBits( 1.2345678901234569 );
        DoubleToLongBits( 1.23456789012345678E+150 );
        DoubleToLongBits( 1.234567890123456789E+300 );
        DoubleToLongBits( double.MinValue );
        DoubleToLongBits( double.MaxValue );
        DoubleToLongBits( double.Epsilon );
        DoubleToLongBits( double.NaN );
        DoubleToLongBits( double.NegativeInfinity );
        DoubleToLongBits( double.PositiveInfinity );
    }
}

/*
This example of the BitConverter.DoubleToInt64Bits( double )
method generates the following output.

          double argument      hexadecimal value
          ---------------      -----------------
  1.0000000000000000E+000       3FF0000000000000
  1.5000000000000000E+001       402E000000000000
  2.5500000000000000E+002       406FE00000000000
  4.2949672950000000E+009       41EFFFFFFFE00000
  3.9062500000000000E-003       3F70000000000000
  2.3283064365386963E-010       3DF0000000000000
  1.2345678901230000E-300       01AA74FE1C1E7E45
  1.2345678901234500E-150       20D02A36586DB4BB
  1.2345678901234565E+000       3FF3C0CA428C59FA
  1.2345678901234567E+000       3FF3C0CA428C59FB
  1.2345678901234569E+000       3FF3C0CA428C59FC
  1.2345678901234569E+150       5F182344CD3CDF9F
  1.2345678901234569E+300       7E3D7EE8BCBBD352
 -1.7976931348623157E+308       FFEFFFFFFFFFFFFF
  1.7976931348623157E+308       7FEFFFFFFFFFFFFF
  4.9406564584124654E-324       0000000000000001
                      NaN       FFF8000000000000
                -Infinity       FFF0000000000000
                 Infinity       7FF0000000000000
*/
open System

let print obj1 obj2 = 
    printfn $"{obj1,25:E16}{obj2,23:X16}"

// Reinterpret the double argument as a long.
let doubleToLongBits argument =
    let longValue = BitConverter.DoubleToInt64Bits argument

    // Display the resulting long in hexadecimal.
    print argument longValue

printfn "This example of the BitConverter.DoubleToInt64Bits(Double) \nmethod generates the following output.\n"
print "double argument" "hexadecimal value"
print "---------------" "-----------------"

// Convert double values and display the results.
doubleToLongBits 1.0
doubleToLongBits 15.0
doubleToLongBits 255.0
doubleToLongBits 4294967295.0
doubleToLongBits 0.00390625
doubleToLongBits 0.00000000023283064365386962890625
doubleToLongBits 1.234567890123E-300
doubleToLongBits 1.23456789012345E-150
doubleToLongBits 1.2345678901234565
doubleToLongBits 1.2345678901234567
doubleToLongBits 1.2345678901234569
doubleToLongBits 1.23456789012345678E+150
doubleToLongBits 1.234567890123456789E+300
doubleToLongBits Double.MinValue
doubleToLongBits Double.MaxValue
doubleToLongBits Double.Epsilon
doubleToLongBits Double.NaN
doubleToLongBits Double.NegativeInfinity
doubleToLongBits Double.PositiveInfinity


// This example of the BitConverter.DoubleToInt64Bits( double )
// method generates the following output.

//           double argument      hexadecimal value
//           ---------------      -----------------
//   1.0000000000000000E+000       3FF0000000000000
//   1.5000000000000000E+001       402E000000000000
//   2.5500000000000000E+002       406FE00000000000
//   4.2949672950000000E+009       41EFFFFFFFE00000
//   3.9062500000000000E-003       3F70000000000000
//   2.3283064365386963E-010       3DF0000000000000
//   1.2345678901230000E-300       01AA74FE1C1E7E45
//   1.2345678901234500E-150       20D02A36586DB4BB
//   1.2345678901234565E+000       3FF3C0CA428C59FA
//   1.2345678901234567E+000       3FF3C0CA428C59FB
//   1.2345678901234569E+000       3FF3C0CA428C59FC
//   1.2345678901234569E+150       5F182344CD3CDF9F
//   1.2345678901234569E+300       7E3D7EE8BCBBD352
//  -1.7976931348623157E+308       FFEFFFFFFFFFFFFF
//   1.7976931348623157E+308       7FEFFFFFFFFFFFFF
//   4.9406564584124654E-324       0000000000000001
//                       NaN       FFF8000000000000
//                        -∞       FFF0000000000000
//                         ∞       7FF0000000000000
' Example of the BitConverter.DoubleToInt64Bits method.
Module DoubleToInt64BitsDemo

    Const formatter As String = "{0,25:E16}{1,23:X16}"
 
    ' Reinterpret the Double argument as a Long.
    Sub DoubleToLongBits( argument As Double )

        Dim longValue    As Long
        longValue = BitConverter.DoubleToInt64Bits( argument )

        ' Display the resulting Long in hexadecimal.
        Console.WriteLine( formatter, argument, longValue )
    End Sub 
       
    Sub Main( )

        Console.WriteLine( _
            "This example of the BitConverter.DoubleToInt64Bits( " & _
            "Double ) " & vbCrLf & "method generates the " & _
            "following output." & vbCrLf )
        Console.WriteLine( formatter, "Double argument", _
            "hexadecimal value" )
        Console.WriteLine( formatter, "---------------", _
            "-----------------" )
          
        ' Convert Double values and display the results.
        DoubleToLongBits( 1.0 )
        DoubleToLongBits( 15.0 )
        DoubleToLongBits( 255.0 )
        DoubleToLongBits( 4294967295.0 )
        DoubleToLongBits( 0.00390625 )
        DoubleToLongBits( 0.00000000023283064365386962890625 )
        DoubleToLongBits( 1.234567890123E-300 )
        DoubleToLongBits( 1.23456789012345E-150 )
        DoubleToLongBits( 1.2345678901234565 )
        DoubleToLongBits( 1.2345678901234567 )
        DoubleToLongBits( 1.2345678901234569 )
        DoubleToLongBits( 1.23456789012345678E+150 )
        DoubleToLongBits( 1.234567890123456789E+300 )
        DoubleToLongBits( Double.MinValue )
        DoubleToLongBits( Double.MaxValue )
        DoubleToLongBits( Double.Epsilon )
        DoubleToLongBits( Double.NaN )
        DoubleToLongBits( Double.NegativeInfinity )
        DoubleToLongBits( Double.PositiveInfinity )
    End Sub 
End Module

' This example of the BitConverter.DoubleToInt64Bits( Double )
' method generates the following output.
' 
'           Double argument      hexadecimal value
'           ---------------      -----------------
'   1.0000000000000000E+000       3FF0000000000000
'   1.5000000000000000E+001       402E000000000000
'   2.5500000000000000E+002       406FE00000000000
'   4.2949672950000000E+009       41EFFFFFFFE00000
'   3.9062500000000000E-003       3F70000000000000
'   2.3283064365386963E-010       3DF0000000000000
'   1.2345678901230000E-300       01AA74FE1C1E7E45
'   1.2345678901234500E-150       20D02A36586DB4BB
'   1.2345678901234565E+000       3FF3C0CA428C59FA
'   1.2345678901234567E+000       3FF3C0CA428C59FB
'   1.2345678901234569E+000       3FF3C0CA428C59FC
'   1.2345678901234569E+150       5F182344CD3CDF9F
'   1.2345678901234569E+300       7E3D7EE8BCBBD352
'  -1.7976931348623157E+308       FFEFFFFFFFFFFFFF
'   1.7976931348623157E+308       7FEFFFFFFFFFFFFF
'   4.9406564584124654E-324       0000000000000001
'                       NaN       FFF8000000000000
'                 -Infinity       FFF0000000000000
'                  Infinity       7FF0000000000000

설명

메서드에서 반환 DoubleToInt64Bits 되는 정수의 비트 순서는 컴퓨터 아키텍처가 little-endian인지 big-endian인지에 따라 달라집니다.

적용 대상

추가 정보