Number of digits in exponent with "g" format?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UmF5IE1pdGNoZWxs?=

    Number of digits in exponent with "g" format?

    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
  • =?UTF-8?B?QXJuZSBWYWpow7hq?=

    #2
    Re: Number of digits in exponent with "g&quot ; format?

    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.0 0000000e+000") will
    always use scientific format with 3 digits in the exponent.

    Arne

    Comment

    • =?Utf-8?B?UmF5IE1pdGNoZWxs?=

      #3
      Re: Number of digits in exponent with "g&quot ; format?



      "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.0 0000000e+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.

      Comment

      • =?UTF-8?B?QXJuZSBWYWpow7hq?=

        #4
        Re: Number of digits in exponent with "g&quot ; format?

        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.0 0000000e+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 (NumberFormatIn fo).

        You will have to find the borders and write some code
        that tests for inside/outside and call code accordingly.

        Arne


        Comment

        Working...