1 Reply Latest reply on Jun 6, 2017 3:24 PM by jveilleux

    Scientific Notation for large and small numbers

    jveilleux

      I did find a function that returns the scientific notation for a number, but it's in text format.  I've tried converting the text to a number (GetAsNumber) but that returns only the mantissa and ignores the exponent (in the form of E+n).  And when this number is exported-to Excel, for example, again you get only the mantissa so you can't do math with it.  Does anyone have a proper form of the scientific notation that gives the correct appearance and that is a proper number on which to perform math operations?

        • 1. Re: Scientific Notation for large and small numbers
          jveilleux

          I just found the solution.  In the SCIN function, drop the space before the "E" and it solves the problem.  It shows up in scientific notation and exports properly.    Here it is:

          /*

          ScientificNotation function

           

          Author

          *COMMENT Visual Realisation

           

          Format

          ScientificNotation ( number ; precision )

           

          Parameters

          number - any numeric expression or field containing a numeric expression

           

          precision - any numeric expression or field containing a numeric expression

           

          Data type returned

          Number (had been text)

           

          Description

          Returns number, rounded off to the specified precision (number of decimal places), formatted in scientific notation.

           

          April 24, 2005

          */

           

          Case (

          number = 0 ; 0 ;

           

          Let ( [

          exponent =  Floor ( Log ( Abs ( number ) ) ) ;

          significand = Round ( SetPrecision ( number / 10^exponent ; 400 ) ; precision )

          ] ;

           

          significand & "E" & Case ( exponent > 0 ; "+" ) & exponent  //remove the space before the E

           

          ) // end Let

          ) // end Case

          1 of 1 people found this helpful