-
Jan 11th, 2001, 12:18 PM
#1
Thread Starter
Junior Member
I would like to round off a number to 4 decimal places
13.58386104
What I'm looking for is 13.5839
Thank you
-
Jan 11th, 2001, 01:30 PM
#2
Fanatic Member
Rounding.
Use the VB Round function.
Code:
MsgBox Round(13.58386104, 4)
Hope this helps!
Later
Digital-X-Treme
Contact me on MSN Messenger: digital_x_treme@hotmail.com
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
-
Jan 12th, 2001, 11:37 AM
#3
New Member
Use the Format function too
Format(13.4582,"0.00") = 13.46
-
Jan 19th, 2001, 05:36 PM
#4
ROUND
when i used round it didn't seem to round correctly with more than 2 decimal places..
-
Jan 20th, 2001, 06:08 AM
#5
Fanatic Member
Possible Solution?
nzer, check to make sure you are using the correct data types. For example, if you store the result of Round() in an integer or long, it will only store the number up to the decimal point. If you store the result of Round() in a Double, then it works fine.
Code:
'Rounds well. Produces 3.21212
Dim x As Double
x = Round(3.21212321334341, 5)
MsgBox x
'Doesn't work. Produces 3
Dim x As Integer
x = Round(3.21212321334341, 5)
MsgBox x
Hope this helps!
Later
Digital-X-Treme
Contact me on MSN Messenger: digital_x_treme@hotmail.com
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
-
Jan 20th, 2001, 06:44 PM
#6
ahh i see
i had my value set to integer... thats probably why!
thanks
-
Feb 5th, 2001, 10:34 AM
#7
New Member
Where A = 13.58386104 then
A = (Int( A * 10000 + .5)) / 10000
A = 13.5839
Additionally if you wanted to round to the nearest lowest 3 DP. then
A = (Int( A * 1000 )) / 1000
A = 13.583
Or Nearest Highest Quarter (For those who work with Imperial dimensions in engineering.)
A = (Int( A * 4 + .9999999 )) / 4
A = 13.750
You could quite easily convert all this into routines. Hope it helps.
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
|