10-08-2020 02:19 AM
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)
Solved! Go to Solution.
10-08-2020 07:06 AM
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.
/Lazo
10-08-2020 05:21 AM
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)
/Lazo
10-08-2020 06:08 AM
Thank you @lazo.ilijoski
I worked with it but, the problem is that if I have the below two values,
42.000
42.568
I want the below output
42
42.568
If I use the parseFloat($NTGEW).toFixed(1) then it will give me the below output
42.0
42.6
10-08-2020 07:06 AM
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.
/Lazo
10-08-2020 08:46 AM
Thank you for your solution indeed it worked.