Hi guys!

If I try 1.565, it will output 1.57

BR,

Donghai

Hi @donghai

You can keep the same and remove. ToString at the end thats it

Math.Round(0.565, 2, MidpointRounding.AwayFromZero)

Try this

Math.Ceiling(0.565 * 100) / 100

or

Math.Round(0.565, 2, MidpointRounding.ToPositiveInfinity)

I hope it helps!!

here CA! is your variable

number is how many numbers you need to have after decimal

0.00 is the format

Hope this helps

1 Like

By using regex also u can try

(Double.Parse(System.Text.RegularExpressions.Regex.Match(“0.565”, “\d+.\d{2}”).Value) + 0.005).ToString(“0.00”))

for the reference you can see the screenshot

By using the regex you can try that

System.text.regularexpression.Regex. Match(“0.563”,“\d+.\d{2}”). Value it will give output as 0.56

@donghai …cheers…!

Hi,

Please try this

Assign:

originalNumber = 0.565

Assign:

roundedNumber=Math.Round(originalNumber, 2)

Message Box:

“Rounded Number:” roundedNumber.ToString

Hi

Have you try this?

yes @donghai

but by using this you get 0.56 value and if you want 0.57 then use below expression.

this will work surely.

Assign activity:

originalNumber = 0.565

roundedNumber = Math.Round(originalNumber + 0.005, 2)

Hi @neha.upase

Thanks your reply.

As you know, It must plus like 0.00001

I have post this way, but I want know is it safe? any bug?

BR,

Donghai

Yes, the approach will work for rounding any number to a specified number of decimal places, including numbers like `5.896556`

. Let’s go through the process step by step using the same approach:

- Original number:
`5.896556`

- Adding
`0.005`

to the original number:`5.896556 + 0.005 = 5.901556`

- Rounding the adjusted number to two decimal places:
`Math.Round(5.901556, 2) = 5.90`

So, for the input `5.896556`

, the code would output the rounded value `5.90`

, which is rounded to two decimal places as per your original requirement.

1 Like

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