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


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

本文整理汇总了VB.NET中System.Decimal.ToDouble方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Decimal.ToDouble方法的具体用法?VB.NET Decimal.ToDouble怎么用?VB.NET Decimal.ToDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Decimal的用法示例。


在下文中一共展示了Decimal.ToDouble方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: DecimalToSgl_DblDemo

' Example of the Decimal.ToSingle and Decimal.ToDouble methods.
Module DecimalToSgl_DblDemo

    Dim formatter As String = "{0,30}{1,17}{2,23}"

    ' Convert the Decimal argument; no exceptions are thrown.
    Sub DecimalToSgl_Dbl( argument As Decimal )

        Dim SingleValue   As Object
        Dim DoubleValue   As Object

        ' Convert the argument to a Single value.
        SingleValue = Decimal.ToSingle( argument )

        ' Convert the argument to a Double value.
        DoubleValue = Decimal.ToDouble( argument )

        Console.WriteLine( formatter, argument, _
            SingleValue, DoubleValue )
    End Sub

    Sub Main( )

        Console.WriteLine( "This example of the " & vbCrLf & _
            "  Decimal.ToSingle( Decimal ) and " & vbCrLf & _
            "  Decimal.ToDouble( Decimal ) " & vbCrLf & "methods " & _
            "generates the following output. It " & vbCrLf & _
            "displays several converted Decimal values." & vbCrLf )
        Console.WriteLine( formatter, "Decimal argument", _
            "Single", "Double" )
        Console.WriteLine( formatter, "----------------", _
            "------", "------" )

        ' Convert Decimal values and display the results.
        DecimalToSgl_Dbl( 0.0000000000000000000000000001D )
        DecimalToSgl_Dbl( 0.0000000000112233445566778899D )
        DecimalToSgl_Dbl( 123D )
        DecimalToSgl_Dbl( New Decimal( 123000000, 0, 0, False, 6 ) )
        DecimalToSgl_Dbl( 123456789.123456789D )
        DecimalToSgl_Dbl( 123456789123456789123456789D )
        DecimalToSgl_Dbl( Decimal.MinValue )
        DecimalToSgl_Dbl( Decimal.MaxValue )
    End Sub 
End Module 

' This example of the
'   Decimal.ToSingle( Decimal ) and
'   Decimal.ToDouble( Decimal )
' methods generates the following output. It
' displays several converted Decimal values.
' 
'               Decimal argument           Single                 Double
'               ----------------           ------                 ------
' 0.0000000000000000000000000001            1E-28                  1E-28
' 0.0000000000112233445566778899     1.122334E-11   1.12233445566779E-11
'                            123              123                    123
'                     123.000000              123                    123
'            123456789.123456789     1.234568E+08       123456789.123457
'    123456789123456789123456789     1.234568E+26   1.23456789123457E+26
' -79228162514264337593543950335    -7.922816E+28  -7.92281625142643E+28
'  79228162514264337593543950335     7.922816E+28   7.92281625142643E+28
开发者ID:VB.NET开发者,项目名称:System,代码行数:61,代码来源:Decimal.ToDouble


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