numeric floating point e-notation

pbenskin
User offline. Last seen 6 weeks 3 days ago. Offline
Joined: 01/31/2011
Points: 100

In my mashups created both by wires and custom with Eclipse, when I group using a sum aggregate my totals over 1 million appear in e-notation (i.e. 1.1284255E6). I am assuming this is because it is perhaps a javascript default? Is there a way to change this setting? Or a way to override it manually with emml?

0
Your rating: None
smitchell
smitchell's picture
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 08/29/2008
Points: 34

It is not some default of JavaScript or Java that you can change. Unfortuantely, all the work arounds that I tried in EMML ended up with the same result.

We are investigating the issue and will get back to you.

 

Sara, technical writer/jackbe

 

smitchell
smitchell's picture
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 08/29/2008
Points: 34

Apologies that this has taken so long to answer. This is happening because of some implicit datatype casting that is happening within the XPath engine in Presto (it isn't in our code which is why it took a while to track down).

There is a simple solution in EMML, which is to apply the xs:decimal() function to the result of your calculation. This function is actually a built-in function in XPath which is defined in the XML Schema standard. So, for a simple addition example:

<mashup name="CalculationTest"
  xmlns="http://www.openmashup.org/schemas/v1.0/EMML"
  xmlns:macro="http://www.openmashup.org/schemas/v1.0/EMMLMacro"
  xmlns:presto="http://www.jackbe.com/v1.0/EMMLPrestoExtensions"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML/../schemas/EMMLPrestoSpec.xsd">

   
<output name="result" type="document"/>
    <variable name="one" type="number" default="900000"/>
    <variable name="two" type="number" default="120000"/>
    <variable name="final" type="document"/>

   
<constructor outputvariable="result">
      <Final>
        <OnePlusTwo>{xs:decimal($one + $two)}</OnePlusTwo>
      </Final>
    </constructor>
</mashup>

gives you a decimal number greater that 1 million.

You can do this in Wires, using the To Decimal function available in Data Decorator, Mapper or Transformer. In some cases, I had to first cast the results of a calculation using To Number and then use To Decimal, so it may be easier to do this in Data Decorator where you can apply multiple functions in one block.

Sara, technical writer/jackbe

 

pbenskin
User offline. Last seen 6 weeks 3 days ago. Offline
Joined: 01/31/2011
Points: 100

This works great Sara. Thank you so much!