Sorry, you're mistaken. Your example happens to produce the result you want, but it is not correct. Here is the background: The way floats/doubles are stored in binary makes it impossible to exactly represent most values, especially the ones that seem like round numbers to humans thinking using base ten. So 4, 2, 1, 0.5, 3.5, 3.75 and many others are representable exactly (basically since they all equal an integer divided by some power of 2); but 3.6 and 3.8 and an infinite number of other values are not. Now whatever float/double function you call, if it returns a float/double will suffer from the same phenomenon. So the only way to really get "3.6" or "3.8" is by using a function that not only rounds but returns a string. I trust there are some formatting methods that do just that in every programming language; In .NET languages ToString() should be one of them, given an appropriate format specifier. If you want to know much more about this topic, here it is: http://docs.sun.com/source/806-3568/ncg\_goldberg.html BTW: to circumvent the floating-point rounding problem, especially for monetary numbers, they introduced the "decimal" data type (which basically stores decimal digits). :)
Luc Pattyn [Forum Guidelines] [My Articles]
Sorry for any delays in replying, I currently don't always get e-mail notifications.