Need to round number as -0.0 in UIPath

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 :stuck_out_tongue:)

Can anyone please help?

@KaustubhVartak

If you still want Negative Sign with 0, then concatenate it with the number :grinning:

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

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