Hi,
I am trying to round number with 1 decimal in UIPath but with following requirement:
if i have a number say -0.005, I want to round the number as -0.0.
Right now, UIPath is considering the number as 0.0 (which is correct mathematically )
Can anyone please help?
Madhuraj
(Madhura Tendulkar)
September 5, 2018, 12:44pm
2
@KaustubhVartak
If you still want Negative Sign with 0, then concatenate it with the number
Regards
Madhura
1 Like
You should have the output from UiPath and prefix - minus sign with the number by casting it to String
1 Like
arivu96
(Arivazhagan A)
September 5, 2018, 5:38pm
4
Hi @KaustubhVartak ,
If you round the -0.005, it will return the value as 0 only.
Because for “0” minuse or plus no matter both are same.
Math.Round(-0.005)
Ans is 0
Math.Round(-1.05)
Ans is -1
Regards,
Arivu
1 Like
After you round it, you can also use .ToString formatting
num.ToString("-0.0")
I believe that will format it to having 1 decimal and with a ‘-’ infront.
EDIT: sorry, you also need to check if it’s negative.
num.ToString(If(num<=0,"-","")+"0.0")
1 Like