ScientificNotation ( number ; precision )
Displays any number in scientific notation.
Average rating: 4.0 (45 votes) Log in to vote
Michael Horak - Show more from this author
*COMMENT Visual Realisation |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Returns (as text) the specified number, rounded off to the specified precision (number of decimal places), formatted in scientific notation.
Filemaker automatically formats numbers greater than 10^9 or smaller than 10^-9 in scientific notation. The ScientificNotation() function enables the display of any number in this format.
Extended precision is used to compute the significand prior to rounding. Thus, the precision parameter supports precisions of up to 400 decimal places. For example, if number is a calculation = SetPrecision ( 22 / 7 ; 400 ), then
ScientificNotation ( number ; 50 ) will return 3.14285714285714285714285714285714285714285714285714 E0.
This function is not recursive.
Comments
Maarten, Private Nov 16, 2009 |
||
there's a little typo in the let (): it says let ( a ... instead of let ( [ .... good stuff all the same. cheers |
||
Ronald W. Satz, Trevose, PA Jul 11, 2013 |
||
Here's a slightly improved version for better formatting. /* ScientificNotation function Author *COMMENT Visual Realisation -- slightly revised by Ronald W. Satz, Transpower Corporation 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 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 ; /*number > 0 and number < 10 ; Round(number;5) ; */ Let ( [ exponent = Floor ( Log ( Abs ( number ) ) ) ; significand = Round ( SetPrecision ( number / 10^exponent ; 400 ) ; precision ) ; significand2 = Case ( Length ( significand ) = 6 ; significand & "0" ; Length ( significand ) = 5 ; significand & "00" ; significand ) ] ; significand2 & "e" & Case ( exponent ≥ 0 ; "+" ) & exponent |
||
Ronald W. Satz, Trevose, PA Jul 12, 2013 |
||
I modified the function again, specifically for a precision level of 5: /* ScientificNotation function Author *COMMENT Visual Realisation -- slightly revised by Ronald W. Satz, Transpower Corporation 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 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 ; /*number > 0 and number < 10 ; Round(number;5) ; */ Let ( [ exponent = Floor ( Log ( Abs ( number ) ) ) ; significand = Round ( SetPrecision ( number / 10^exponent ; 400 ) ; precision ) ; significand2 = Case ( Length ( significand ) = 6 ; significand & "0" ; // this and those below will work for a precision of 5--modify if necessary Length ( significand ) = 5 ; significand & "00" ; Length ( significand ) = 4 ; significand & "000" ; Length ( significand ) = 3 ; significand & "0000" ; significand ) ] ; significand2 & "e" & Case ( exponent ≥ 0 ; "+" ) & exponent ) // end Let ) // end Case |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.