本文整理匯總了VB.NET中System.Decimal.GetBits方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Decimal.GetBits方法的具體用法?VB.NET Decimal.GetBits怎麽用?VB.NET Decimal.GetBits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Decimal
的用法示例。
在下文中一共展示了Decimal.GetBits方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
Module Example
Public Sub Main()
' Define an array of decimal values.
Dim values() As Decimal = { 1d, 100000000000000d,
10000000000000000000000000000d,
100000000000000.00000000000000d,
1.0000000000000000000000000000d,
123456789d, 0.123456789d,
0.000000000123456789d,
0.000000000000000000123456789d,
4294967295d,
18446744073709551615d,
Decimal.MaxValue, Decimal.MinValue,
-7.9228162514264337593543950335d }
Console.WriteLine("{0,31} {1,10:X8}{2,10:X8}{3,10:X8}{4,10:X8}",
"Argument", "Bits[3]", "Bits[2]", "Bits[1]",
"Bits[0]" )
Console.WriteLine( "{0,31} {1,10:X8}{2,10:X8}{3,10:X8}{4,10:X8}",
"--------", "-------", "-------", "-------",
"-------" )
' Iterate each element and display its binary representation
For Each value In values
Dim bits() As Integer = Decimal.GetBits(value)
Console.WriteLine("{0,31} {1,10:X8}{2,10:X8}{3,10:X8}{4,10:X8}",
value, bits(3), bits(2), bits(1), bits(0))
Next
End Sub
End Module
輸出:
Argument Bits(3) Bits(2) Bits(1) Bits(0) -------- ------- ------- ------- ------- 1 00000000 00000000 00000000 00000001 100000000000000 00000000 00000000 00005AF3 107A4000 10000000000000000000000000000 00000000 204FCE5E 3E250261 10000000 100000000000000.00000000000000 000E0000 204FCE5E 3E250261 10000000 1.0000000000000000000000000000 001C0000 204FCE5E 3E250261 10000000 123456789 00000000 00000000 00000000 075BCD15 0.123456789 00090000 00000000 00000000 075BCD15 0.000000000123456789 00120000 00000000 00000000 075BCD15 0.000000000000000000123456789 001B0000 00000000 00000000 075BCD15 4294967295 00000000 00000000 00000000 FFFFFFFF 18446744073709551615 00000000 00000000 FFFFFFFF FFFFFFFF 79228162514264337593543950335 00000000 FFFFFFFF FFFFFFFF FFFFFFFF -79228162514264337593543950335 80000000 FFFFFFFF FFFFFFFF FFFFFFFF -7.9228162514264337593543950335 801C0000 FFFFFFFF FFFFFFFF FFFFFFFF
示例2: Example
Module Example
Public Sub Main()
Dim values() As Decimal = { 1234.96d, -1234.96d }
For Each value In values
Dim parts() = Decimal.GetBits(value)
Dim sign As Boolean = (parts(3) And &h80000000) <> 0
Dim scale As Byte = CByte((parts(3) >> 16) And &H7F)
Dim newValue As New Decimal(parts(0), parts(1), parts(2), sign, scale)
Console.WriteLine("{0} --> {1}", value, newValue)
Next
End Sub
End Module
輸出:
1234.96 --> 1234.96 -1234.96 --> -1234.96
示例3: Test
public class Test
public Shared Sub Main
Dim D1, D2 As Decimal
D1 = 10
D2 = 5.7
Console.WriteLine(Decimal.GetBits(3).GetValue(0))
End Sub
End class