Using the parsed Float value in string

I have double value coming from the source as a string.
Source value:

“NTGEW” : “3.400”

I am using parseFloat() function to convert the string into double value.

parseFloat($NTGEW) ===> 3.4

The parseFloat function is working as expected when it is the only function as show above.

But if I use the same function with string concatenation it is appending the double value with trailing zeros as shown below:

“Input Value” + parseFloat($NTGEW) ===> “Input Value 3.400”

The expected value should be ===> “Input Value 3.4”

Any suggestions would be appreciated.floatIssue_2020_10_08.slp (4.8 KB)

Hi @patan,

You can use the following statement:
"Input Value "+parseFloat($NTGEW).toFixed(1)

Attached herewith you can find the updated pipeline. floatIssue_2020_10_08_new.slp (4.8 KB)


1 Like

Thank you @lazo.ilijoski
I worked with it but, the problem is that if I have the below two values,


I want the below output


If I use the parseFloat($NTGEW).toFixed(1) then it will give me the below output


Maybe initially I didn’t understand well your issue.
You can use the following statement with regex:
"Input Value “+ ((parseInt($NTGEW) == parseFloat($NTGEW)) ? parseInt($NTGEW).toString() : (parseFloat($NTGEW).toString()+“0”).match(”(.*d?[1-9])0+$")[1])*

So, I did tests with few cases and got the following result:

And here is updated pipeline:
floatIssue_2020_10_08_v2.slp (5.2 KB)

Please let me know if this version works as expected.




Thank you for your solution indeed it worked.