64 ビット符号付き整数を Decimal に変換します。
returnValue = Decimal.op_Implicit(value)
[C#]
public static implicit operator decimal(longvalue);
[C++]
public: static Decimal op_Implicit(__int64value);
[JScript]
returnValue = value;
[Visual Basic] Visual Basic では、この型で定義されている型変換を使用することができます。ただし、独自に定義することはできません。
[JScript] JScript では、この型で定義されている型変換を使用することができます。ただし、独自に定義することはできません。
引数 [Visual Basic, JScript]
- value
64 ビット符号付き整数。
パラメータ [C#, C++]
- value
64 ビット符号付き整数。
戻り値
変換された 64 ビット符号付き整数を表す Decimal 。
使用例
[Visual Basic, C#, C++] Int64 to Decimal 変換を使用して Int64 の値を Decimal の数値に変換するコード例を次に示します。この変換は C# では暗黙で行われますが、Visual Basic および C++ では op_Implicit 演算子が必要です。これらの言語では、 Decimal への暗黙の変換には、他のメソッドが使用されます。
' Example of the op_Implicit conversion from Long to Decimal.
Imports System
Imports Microsoft.VisualBasic
Module DecimalFromInt64Demo
Const formatter As String = _
"{0,20}{1,21}{2,10:X8}{3,9:X8}{4,9:X8}{5,9:X8}"
' Convert the Long argument and display the Decimal value.
Sub DecimalFromInt64( argument As Long )
Dim decValue As Decimal
Dim bits( ) As Integer
' The compiler invokes a constructor in Visual Basic
' unless op_Implicit is explicitly called.
decValue = Decimal.op_Implicit( argument )
' Display the Decimal and its binary representation.
bits = Decimal.GetBits( decValue )
Console.WriteLine( formatter, argument, decValue, _
bits( 3 ), bits( 2 ), bits( 1 ), bits( 0 ) )
End Sub
Sub Main( )
Console.WriteLine( _
"This example of the op_Implicit conversion from Long " & _
"to Decimal generates the " & vbCrLf & "following " & _
"output. It displays the Decimal value and its " & _
"binary representation." & vbCrLf )
Console.WriteLine( formatter, "Long argument", _
"Decimal value", "bits(3)", "bits(2)", _
"bits(1)", "bits(0)" )
Console.WriteLine( formatter, "-------------", _
"-------------", "-------", "-------", _
"-------", "-------" )
' Convert Long values and display the results.
DecimalFromInt64( Long.MinValue )
DecimalFromInt64( Long.MaxValue )
DecimalFromInt64( &HFFFFFFFFFFFF )
DecimalFromInt64( 123456789123456789 )
DecimalFromInt64( - 1000000000000000 )
End Sub
End Module
' This example of the op_Implicit conversion from Long to Decimal generates the
' following output. It displays the Decimal value and its binary representation.
'
' Long argument Decimal value bits(3) bits(2) bits(1) bits(0)
' ------------- ------------- ------- ------- ------- -------
' -9223372036854775808 -9223372036854775808 80000000 00000000 80000000 00000000
' 9223372036854775807 9223372036854775807 00000000 00000000 7FFFFFFF FFFFFFFF
' 281474976710655 281474976710655 00000000 00000000 0000FFFF FFFFFFFF
' 123456789123456789 123456789123456789 00000000 00000000 01B69B4B ACD05F15
' -1000000000000000 -1000000000000000 80000000 00000000 00038D7E A4C68000
[C#]
// Example of the implicit conversion from long to decimal.
using System;
class DecimalFromInt64Demo
{
const string formatter =
"{0,20}{1,21}{2,10:X8}{3,9:X8}{4,9:X8}{5,9:X8}";
// Convert the long argument and display the decimal value.
public static void DecimalFromInt64( long argument )
{
decimal decValue;
int[ ] bits;
// Display the decimal and its binary representation.
decValue = argument;
bits = decimal.GetBits( decValue );
Console.WriteLine( formatter, argument, decValue,
bits[ 3 ], bits[ 2 ], bits[ 1 ], bits[ 0 ] );
}
public static void Main( )
{
Console.WriteLine(
"This example of the implicit conversion from long " +
"to decimal generates the \nfollowing output. It " +
"displays the decimal value and its binary " +
"representation.\n" );
Console.WriteLine( formatter, "long argument",
"decimal value", "bits[3]", "bits[2]",
"bits[1]", "bits[0]" );
Console.WriteLine( formatter, "-------------",
"-------------", "-------", "-------",
"-------", "-------" );
// Convert long values and display the results.
DecimalFromInt64( long.MinValue );
DecimalFromInt64( long.MaxValue );
DecimalFromInt64( 0xFFFFFFFFFFFF );
DecimalFromInt64( 123456789123456789 );
DecimalFromInt64( -1000000000000000 );
}
}
/*
This example of the implicit conversion from long to decimal generates the
following output. It displays the decimal value and its binary representation.
long argument decimal value bits[3] bits[2] bits[1] bits[0]
------------- ------------- ------- ------- ------- -------
-9223372036854775808 -9223372036854775808 80000000 00000000 80000000 00000000
9223372036854775807 9223372036854775807 00000000 00000000 7FFFFFFF FFFFFFFF
281474976710655 281474976710655 00000000 00000000 0000FFFF FFFFFFFF
123456789123456789 123456789123456789 00000000 00000000 01B69B4B ACD05F15
-1000000000000000 -1000000000000000 80000000 00000000 00038D7E A4C68000
*/
[C++]
// Example of the op_Implicit conversion from __int64 to Decimal.
#using <mscorlib.dll>
using namespace System;
const __wchar_t* formatter =
L"{0,20}{1,21}{2,10:X8}{3,9:X8}{4,9:X8}{5,9:X8}";
// Convert the __int64 argument and display the Decimal value.
void DecimalFromInt64( __int64 argument )
{
Decimal decValue;
Int32 bits[ ];
// The compiler invokes a constructor in the Managed Extensions
// for C++ unless op_Implicit is explicitly called.
decValue = Decimal::op_Implicit( argument );
// Display the Decimal and its binary representation.
bits = Decimal::GetBits( decValue );
Console::WriteLine( formatter, __box( argument ),
__box( decValue ), __box( bits[ 3 ] ),
__box( bits[ 2 ] ), __box( bits[ 1 ] ), __box( bits[ 0 ] ) );
}
void main( )
{
Console::WriteLine(
S"This example of the op_Implicit conversion from "
S"__int64 to Decimal \ngenerates the following output. "
S"It displays the Decimal value and \nits binary "
S"representation.\n" );
Console::WriteLine( formatter, S"__int64 argument",
S"Decimal value", S"bits[3]", S"bits[2]",
S"bits[1]", S"bits[0]" );
Console::WriteLine( formatter, S"----------------",
S"-------------", S"-------", S"-------",
S"-------", S"-------" );
// Convert __int64 values and display the results.
DecimalFromInt64( Int64::MinValue );
DecimalFromInt64( Int64::MaxValue );
DecimalFromInt64( 0xFFFFFFFFFFFF );
DecimalFromInt64( 123456789123456789 );
DecimalFromInt64( -1000000000000000 );
}
/*
This example of the op_Implicit conversion from __int64 to Decimal
generates the following output. It displays the Decimal value and
its binary representation.
__int64 argument Decimal value bits[3] bits[2] bits[1] bits[0]
---------------- ------------- ------- ------- ------- -------
-9223372036854775808 -9223372036854775808 80000000 00000000 80000000 00000000
9223372036854775807 9223372036854775807 00000000 00000000 7FFFFFFF FFFFFFFF
281474976710655 281474976710655 00000000 00000000 0000FFFF FFFFFFFF
123456789123456789 123456789123456789 00000000 00000000 01B69B4B ACD05F15
-1000000000000000 -1000000000000000 80000000 00000000 00038D7E A4C68000
*/
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン
をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard