本文整理汇总了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