|
-
Nov 26th, 2008, 08:42 PM
#1
Thread Starter
Member
[RESOLVED] Trouble with code to round down a number
Hi there,
I obtained code to round down a number to a second non-zero digit. Unfortunately, it doesn't work properly. When dblX is 82.02, I would like to round down this number to 82. Would you have any idea how to modify the code so that I works properly?
Thanks for your help!
Public Function RoundDown2ndDigit(ByVal dblX As Double, Optional ByVal dblStep As Double) As Double
Dim strE As String, dblM As Double
strE = Format(Abs(dblX), "0.0E+0")
dblStep = CDbl("0.1E" & Mid(strE, 5))
dblM = CDbl(strE)
If dblM > Abs(dblX) Then dblM = dblM + dblStep
RoundDown2ndDigit = (Sgn(dblX) * dblM)
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|