I'm trying to wrap my head around formatting decimals.
I have a specification that needs to be met, and it's outlined as follows:
For decimals between +/-0.0000001 and +/-100000: Optional ‘-‘ character, followed by 5 significant digits before the decimal, a ‘.’ character, followed by 6 significant digits after the decimal. If less than 5 significant digits before the decimal, pad with spaces; the optional ‘-‘ character will be right justified. If less than 6 significant digits after the decimal, pad with zeros.
For decimals below -100000 or above 100000: Optional ‘-‘ character, followed by “0.” and 6 significant digits, followed by ‘E’, followed by ‘-‘ or ‘+’, followed by a 2 digit exponent. If the value has less than 6 significant digits, pad with zeros. If the exponent has less than 2 significant digits, pad with zeros.
For 0.0m: "_____0.000000" (<-- where _ means space)
I've read the following MSDN articles:
...and they've helped me wrap my head around some rather simple cases, but the one above is quite complex and I'm getting very confused (especially with the whitespace padding--is that even possible?). Can anyone help me construct a format string that will meet the above specifications?