Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-23263

Decimal128: Scientific notation

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.8
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Fully Compatible
    • Integrate+Tuning 14 (05/13/16), Integrate+Tuning 15 (06/03/16)

      Apparently there is a standard for when to use scientific.

      See: http://speleotrove.com/decimal/daconvs.html#reftostr

      to-scientific-string – conversion to numeric string

      This operation converts a number to a string, using scientific notation if an exponent is needed. The operation is not affected by the context.
      
      If the number is a finite number then:
      
          The coefficient is first converted to a string in base ten using the characters 0 through 9 with no leading zeros (except if its value is zero, in which case a single 0 character is used).
          Next, the adjusted exponent is calculated; this is the exponent, plus the number of characters in the converted coefficient, less one. That is, exponent+(clength-1), where clength is the length of the coefficient in decimal digits.
          If the exponent is less than or equal to zero and the adjusted exponent is greater than or equal to -6, the number will be converted to a character form without using exponential notation. In this case, if the exponent is zero then no decimal point is added. Otherwise (the exponent will be negative), a decimal point will be inserted with the absolute value of the exponent specifying the number of characters to the right of the decimal point. ‘0’ characters are added to the left of the converted coefficient as necessary. If no character precedes the decimal point after this insertion then a conventional ‘0’ character is prefixed.
          Otherwise (that is, if the exponent is positive, or the adjusted exponent is less than -6), the number will be converted to a character form using exponential notation. In this case, if the converted coefficient has more than one digit a decimal point is inserted after the first digit. An exponent in character form is then suffixed to the converted coefficient (perhaps with inserted decimal point); this comprises the letter ‘E’ followed immediately by the adjusted exponent converted to a character form. The latter is in base ten, using the characters 0 through 9 with no leading zeros, always prefixed by a sign character (‘-’ if the calculated exponent is negative, ‘+’ otherwise). 
      

            Assignee:
            vincent.do@mongodb.com Vincent Do
            Reporter:
            bjori Hannes Magnusson
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: