Convert string to long

4
Hi there, I am in desperate need to convert a string value to a long value. I've tried round(parseFloat('10101309124048')), and parseInteger('10101309124048') and I am not sure what else I could be using as it seems that all the conversion functions returns integers that will cause the application to break as integers cannot handle such big numbers. I logged a bug report as I encountered the same error when retrieving a Long value from a web service, but now I need to do a conversion in a micrflow. Has anybody ever succeeded in doing this? Or should I include this in my bug report? Kind Regards Frikkie Chalmers
asked
1 answers
5

If all the functions indeed return integers, perhaps a workaround like this will work:

if length($myString) < 10
then parseInteger($myString)
else parseInteger(substring($myString, 0, length($myString) - 9)) * 1000000000 
+ parseInteger(substring($myString, length($myString) - 9, 9))

Note that the above expression will not parse all negative values correctly and doesn't work for values larger than MaxIntValue * 1000000000, but you could extend the expression to deal with these cases.

answered