Private Function getAroundPrecisionBug(ByVal value As Decimal)
Dim x As Decimal
'get decimal value
Dim y As Decimal = value - Math.Floor(value)
If y >= 0.5 Then
x = Math.Ceiling(value)
Else
x = Math.Floor(value)
End If
Return x
End Function
The integer nearest parameter d. If d is halfway between two integers, one of which is even and the other odd, then the even number is returned.
So CInt(99.5) is 100 and CInt(98.5) is 98, you see? Since it's "banker's rounding" it should be exactly what you need for your money.The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding.
Dim i As Integer = Math.Round(98.5, MidpointRounding.AwayFromZero) '=99