example: 1/2 in string to 0.5 in decimal
Hey, there is no direct method available in .net. However you can create a logic which convert fraction text to decimal value. I have used https://stackoverflow.com/questions/13903621/convert-a-text-fraction-to-a-decimal and it works. I had a similar requirement.
You can implement the same logic in UiPath and create a Library or create a custom activity.
This would not work I guess as input format is in Text.
CDbl(“1/2”) --> This will throw an exception.
Hi @lakshman can you please elaborate on it?
What i want is to convert string to a fraction.
Example: CDbl(“1/2”) to 0.5 decimal
is this possible?
If, Str1 (String) = “1/2”
Then, use assign
Number (Double) = CDbl(CDbl(str1.Split("/"C)(0))/CDbl(str1.Split("/"C)(1)))
writeline —> Number.Tostring
You’ll see the output —> 0.5
Also we need to check the second part is not a “Zero”
I don’t think so @sarathi125
- If numerator is 0 then it’ll give output as 0.
- If denominator is 0 then it’ll give output as Infinity.
Which is correct.