4 Replies Latest reply on Jan 10, 2017 9:26 AM by jveilleux

    how do I convert a number to exponential form


      Filemaker doesn't provide a good scientific format for numbers.  Has anyone come up with a way to convert a number to the exponential form with a specified number of significant digits and appropriate rounding?  For example, 0.0003258788... would become 3.26E-4

        • 1. Re: how do I convert a number to exponential form

          I'd check sites such as the Brian Dunning site that are used to share custom functions to see if there's a CF for this. I'd expect that someone has already worked out the math needed to do what you want here.

          • 3. Re: how do I convert a number to exponential form



            Depending on where / how you're needing this, this is super easy with JavaScript


            JavaScript toExponential() Method



            Java does this conversion automatically, even without defining a "Formatter" object.


            double number 0.000325878839393939;

            System.out.println("Number entered is: "+ number);


            Prints: Number entered is: 3.25878839393939E-4


            (using a Formatter, you could specify any number of digits and if by chance the number exceeds what a "double" can hold, you can always create a "BigDecimal" object which can be any arbitrary size. Any size needed.)



            If the CF referenced above doesn't fix your situation, there might be a plug-in that does what you need. That CF author seems quite popular.




            For stuff like this, I add a GET method to a micro-service and do it that way so I can leverage what FMP does well without getting frustrated by the limitations in its functions (or just plain missing functions).


            Plus, using a service approach, that logic works across ANY application that can do an HTTP GET. (and it's all free.)


            For scripts, FileMaker's INSERT FROM URL works great here to connect to services. Or for FMP calculations, you could use the free FMP plug-in library, "BE", and do a CURL command. (Although I rarely use it, that BE library is chocked full of good stuff.)




            More drastic, but to me less appealing since it's FMP-ONLY, you could write your own FMP plug-in. Not as difficult as it sounds, but expect some downtime getting everything set up.




            HOPE THIS HELPS.

            • 4. Re: how do I convert a number to exponential form

              thanks for the help--that function did the trick.