# How to round 0.565 to 0.57?

Hi guys!

If I try 1.565, it will output 1.57

BR,
Donghai

Hi @donghai

Math.Ceiling(1.565 * 100) / 100

Hi @donghai

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

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

@donghai

Try this

Math.Ceiling(0.565 * 100) / 100

or

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

I hope it helps!!

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

@donghai

If the number is 0.563, I want get 0.56, your solution will 0.57.

BR,
Donghai

I donâ€™t know are there any bugs, If I chose this way.

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,

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)

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:

1. Original number: `5.896556`
2. Adding `0.005` to the original number: `5.896556 + 0.005 = 5.901556`
3. 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.