Hello, By default, the "g" format specifier seems to use 2 digits in the exponent if it decides to use the scientific format. I.e., Double.ToString("g"). How do I control the number of exponent digits used without affecting the operation of "g" in any other way? I need it to use 3 digits instead. Thanks, Ray
Ray Mitchell wrote: > By default, the "g" format specifier seems to use 2 digits in the exponent > if it decides to use the scientific format. I.e., Double.ToString("g"). How > do I control the number of exponent digits used without affecting the > operation of "g" in any other way? I need it to use 3 digits instead. Something like x.ToString("e") or x.ToString("0.00000000e+000") will always use scientific format with 3 digits in the exponent. Arne
"Arne Vajhøj" wrote: > Ray Mitchell wrote: > > By default, the "g" format specifier seems to use 2 digits in the exponent > > if it decides to use the scientific format. I.e., Double.ToString("g"). How > > do I control the number of exponent digits used without affecting the > > operation of "g" in any other way? I need it to use 3 digits instead. > > Something like x.ToString("e") or x.ToString("0.00000000e+000") will > always use scientific format with 3 digits in the exponent. > > Arne > Yes, but I don't always want scientific. I want it to be done like "g" does it except that when it does "choose" scientific, it uses 3 digits of exponent instead of 2.
Ray Mitchell wrote: > "Arne Vajhøj" wrote: >> Ray Mitchell wrote: >>> By default, the "g" format specifier seems to use 2 digits in the exponent >>> if it decides to use the scientific format. I.e., Double.ToString("g"). How >>> do I control the number of exponent digits used without affecting the >>> operation of "g" in any other way? I need it to use 3 digits instead. >> Something like x.ToString("e") or x.ToString("0.00000000e+000") will >> always use scientific format with 3 digits in the exponent. > > Yes, but I don't always want scientific. I want it to be done like "g" does > it except that when it does "choose" scientific, it uses 3 digits of exponent > instead of 2. Unfortunately there does not seem to be support for that in .NET (NumberFormatInfo). You will have to find the borders and write some code that tests for inside/outside and call code accordingly. Arne