Skip to main content
Solved

JSONTemplater displaying floats values go long


oliver.morris
Contributor
Forum|alt.badge.img+12

I am pushing data that I have cast as a double number to the JSONTemplater - it goes in as 0.09 once it comes out it gets longer becoming: "prod_index" : 0.09000000000000001

This seems like a floating point rounding number issue. Can anyone suggest a way around this.

Many Thanks,

Oliver

 

Best answer by david_r

Try something like:

{
    "prod_index": fn:round(fme:get-attribute("prod_index"), 2)
}

 

View original
Did this help you find an answer to your question?

3 replies

david_r
Celebrity
  • Best Answer
  • March 20, 2019

Try something like:

{
    "prod_index": fn:round(fme:get-attribute("prod_index"), 2)
}

 


oliver.morris
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • March 20, 2019
david_r wrote:

Try something like:

{
    "prod_index": fn:round(fme:get-attribute("prod_index"), 2)
}

 

did the trick thank you, it is a pity those functions arent listed in the text editor functions list on the left hand side.


david_r
Celebrity
  • March 20, 2019
oliver.morris wrote:

did the trick thank you, it is a pity those functions arent listed in the text editor functions list on the left hand side.

I agree. But you can find more information by googling for XQuery functions, e.g. "xquery round" etc.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings