当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET Decimal.GetBits方法代码示例

本文整理汇总了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
开发者ID:VB.NET开发者,项目名称:System,代码行数:31,代码来源:Decimal.GetBits

输出:

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
开发者ID:VB.NET开发者,项目名称:System,代码行数:13,代码来源:Decimal.GetBits

输出:

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
开发者ID:VB程序员,项目名称:System,代码行数:11,代码来源:Decimal.GetBits


注:本文中的System.Decimal.GetBits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。