Hi,
Is there a easier way of rounding of a double
I use the following
thanksCode:dim test1 as double
test1 = math.round(a*b, 2)
Printable View
Hi,
Is there a easier way of rounding of a double
I use the following
thanksCode:dim test1 as double
test1 = math.round(a*b, 2)
That is THE way. It isn't exactly hard.
thanks;
Is there an option like
Code:test1 = (a * b).ToString.Format("0.00")
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.
Thanks JMC for the clarification...