这是VBA舍入函数中的错误吗?如果是这样,谁知道它何时/为什么发生?

时间:2018-12-12 13:38:18

标签: excel vba excel-vba rounding

我用这段代码打印了一些舍入输出。

Private Sub TestRound()

    Dim i As Double
    Dim vTest As Double

    vTest = 17.005

    For i = 1 To 10
        Debug.Print vTest, Round(vTest, 2)
        vTest = vTest + 0.01
    Next i

End Sub

以下是输出(初始值,舍入值):

( 17.005,        17 )
( 17.015,        17.02 )
( 17.025,        17.03 )
( 17.035,        17.04 )
( 17.045,        17.05 )
( 17.055,        17.06 )
( 17.065,        17.07 )
( 17.075,        17.08 )
( 17.085,        17.09 )
( 17.095,        17.1 )

0 个答案:

没有答案