Public Shared Function DoubleNearEst(ByVal dblValue As Double, Optional ByVal UpDown As String = "U", Optional ByVal Nearest As Double = 0.25) As Double
Return If(UpDown.ToUpper() = "U", System.Math.Ceiling(dblValue / Nearest), System.Math.Floor(dblValue / Nearest)) * Nearest
End Function
Public Shared Function DoubleNearEst(ByVal dblValue As Double, Optional ByVal UpDown As String = "U", Optional ByVal Nearest As Double = 0.25) As Double
Return If(UpDown.ToUpper() = "U", System.Math.Ceiling(dblValue / Nearest), System.Math.Floor(dblValue / Nearest)) * Nearest
End Function
ผมคิดว่าคุณคงมีต้นทุนเพิ่มเติม (+0.0)
Code (VB.NET)
Public Shared Function DoubleNearEst(ByVal dblValue As Double, Optional ByVal UpDown As String = "U", Optional ByVal Nearest As Double = 0.25) As Double
Return If(UpDown.ToUpper() = "U", System.Math.Ceiling(dblValue + 0.0 / Nearest), System.Math.Floor(dblValue +0.0/ Nearest)) * Nearest
End Function