I have a number 6.5149598935246 4 that I need to round to 6.51
I am using the following code:
Public Function MyRound(dblInpu t As Currency, intDecimal As Integer) As Double
If dblInput < 0 Then
MyRound = -Int(CDec((Abs(d blInput) * 10 ^ intDecimal) + 0.5)) / 10 ^ intDecimal
Else
MyRound = Int(CDec((dblIn put * 10 ^ intDecimal) + 0.5)) / 10 ^ intDecimal
End If
End Function
When I step into the code what is actually going through the MyRound code is 6.515 so it makes sense that it is rounding to 6.52 but I do not know why it is rounding from 6.5149598935246 4 to 6.515.
It's probably very simple but I'm not seeing it.
I am using the following code:
Public Function MyRound(dblInpu t As Currency, intDecimal As Integer) As Double
If dblInput < 0 Then
MyRound = -Int(CDec((Abs(d blInput) * 10 ^ intDecimal) + 0.5)) / 10 ^ intDecimal
Else
MyRound = Int(CDec((dblIn put * 10 ^ intDecimal) + 0.5)) / 10 ^ intDecimal
End If
End Function
When I step into the code what is actually going through the MyRound code is 6.515 so it makes sense that it is rounding to 6.52 but I do not know why it is rounding from 6.5149598935246 4 to 6.515.
It's probably very simple but I'm not seeing it.
Comment