I'm looking for a String.Format() specifier in the .NET Framework that will permit this:
-- For values ranging between 0 and 1, a leading number (0 or 1), the decimal separator, and three digits after, for example. 0.995, 1.000, 0.015
-- Ranging between 0 and 100, two decimal places: 0.00, 5.46, 10.0
-- Ranging between 100 and 10000, no decimal places: 543, 886, 2576
Essentially, I think want four significant digits, where the decimal places appear only if the number is very small. None of my outputs have negative values. EDIT: I need to avoid scientific notation.
Is there a format specifier that can give me something close to that? Or, alternatively, a regular expression that would modify a double-precision string (like "43667.73625003946255") to produce it?
IFormatProvider? - D StanleyIFormatProviderI'll use that, though! - Rob Perkins