How to convert string to double keeping "," in string as decimal separator

Hey Guys!

I am facing a problem that I cannot resolve and need help.

In my workflow using regex I extract numbers as a string in this format: 1234,12. Important thing is, that the “,” is the decimal separator. I have to convert this string to double type thus I can perform mathematical operations with it.
When converting this string to double the new variable “drops” the “,” and results in this format: 123412. I believe the conversion omitting the “,” is due to the fact that it is considered as a searator for thousands (like in 100,000 = one hundred thousand).

(Whatsmore! in another section of the same workflow there is no problem of the kind with conversion to double (though there I perform something different: ASSIGN: doubleVAR=doubleVAR+Convert.toDouble(genericVAR.toString) )

Is there a way to come up with a string to double conversion resulting in the desired format (1234,12)?

Could someone please help me overcome this?

Hi @oralolle

well try and use this on the string before converting it

StrToConvert.Replace(“,”,“.”)
Main.xaml (5.2 KB)

here is a little xaml to prove the point
hope it helps
Reda

1 Like

Hi @reda

I tried and double conversion works, BUT the output format is 125.28 (NOT 125,28). Does this mean that double format can never “look” like as I expect? (125,28)

Well if you want to have a smooth conversion from 215,28 to double and keep the right number, you can use the culture class as described in the process below.

What I want to mention though is that whenever you will display the double you have to make toString conversion, so why bother forcing the representation with the comma while you can work smoothly on doubles with the normal representation, and whenever you need to display them add this to the end ToString.Replace(“.”,“,”)

Main.xaml (6.1 KB)

5 Likes

Thanks @reda, i will proceed according to your suggestion!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.