Formatting with Minimum and Maximum Places
-
I can't seem to find a way to format a float, to always have at least two places, but will include up to n places when required, i.e. it will render three places if required, but no trailing zero when only two places are required. Then, why is my number always rounded to two places in the following example? float f = 22223.430321F; MessageBox.Show(string.Format("{0:0.0000}", f));
-
I can't seem to find a way to format a float, to always have at least two places, but will include up to n places when required, i.e. it will render three places if required, but no trailing zero when only two places are required. Then, why is my number always rounded to two places in the following example? float f = 22223.430321F; MessageBox.Show(string.Format("{0:0.0000}", f));
-
Have you seen this article? http://www.csharp-examples.net/string-format-double/[^]
No, thanks. I've since learned that the default for float is rounding to two places, regardless of formatting, and I missed the conversion from SQL float to CLR double. I can work with a double as expected.