|
-
May 21st, 2007, 05:17 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Rounding of Digits in a Double
Hi,
Is there a easier way of rounding of a double
I use the following
Code:
dim test1 as double
test1 = math.round(a*b, 2)
thanks
-
May 21st, 2007, 05:22 AM
#2
Re: [2005] Rounding of Digits in a Double
That is THE way. It isn't exactly hard.
-
May 21st, 2007, 05:30 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] Rounding of Digits in a Double
thanks;
Is there an option like
Code:
test1 = (a * b).ToString.Format("0.00")
-
May 21st, 2007, 05:33 AM
#4
Re: [2005] Rounding of Digits in a Double
1. How is that easier?
2. Your 'test1' variable is a Double, so why would you be converting a value that is already a Double to String? You'd only have to convert back again to a Double.
If you actually want a string, like to display in a Label or whatever then you can use myDouble.ToString("n2") or myDouble.ToString("f2"), but only do that if you catually want a string. Don't convert things to strings and back again without a very good reason. If there's a simple way to do what you want with the value's original type then that's what you should do.
Last edited by jmcilhinney; May 21st, 2007 at 05:36 AM.
-
May 21st, 2007, 05:38 AM
#5
Thread Starter
Hyperactive Member
Re: [2005] Rounding of Digits in a Double
Thanks JMC for the clarification...
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
|