Variables:

VarAmount (Double) = 13706.505

RoundOffLimit (Int32) = 2

Activities:

Assign:

- To: rounded_amount
- Value: Math.Round(VarAmount, RoundOffLimit)

Write Line:

- Text: rounded_amount.ToString

Variables:

VarAmount (Double) = 13706.505

RoundOffLimit (Int32) = 2

Activities:

Assign:

- To: rounded_amount
- Value: Math.Round(VarAmount, RoundOffLimit)

Write Line:

- Text: rounded_amount.ToString

i tried it but it is giving me 13706.50

```
Assign activity:
VarAmount = 13706.505
RoundOfLimit = 2
Assign activity:
VarAmount = Math.Ceiling(VarAmount * Math.Pow(10, RoundOfLimit)) / Math.Pow(10, RoundOfLimit)
```

1 Like

this can happen due the internal precision and as we do see the .505 is with the last 5 within the middle and let’s not flip to 51

your code is having only one decimal place, please try it with 3 decimal places. Like 123.325, then it should give as 123.33 in result

but Sir, it is business requirement

it is not a problem. Once we have understood the technical base we can take care of and fullfill the business requirement

1 Like

Hi @adishjain

- Read the value of
`VarAmount`

from your data source or variable. - Read the value of
`RoundOfLimit`

from your config file or variable. In your case, it’s 2. - Use the
`Math.Round`

method to round`VarAmount`

to the specified number of decimal places (`RoundOfLimit`

).

VarAmount = Math.Round(VarAmount, RoundOfLimit)

VarAmount = Math.Round(13706.505, 2)

Hope it helps!!

You can try:

it is giving me 13706.50

yes it is working sir, thankyou so much

it is working for me, thankyou

1 Like

we should also keep in mind that after a certain precision the portion is ignored:

Acrobatics like multiply / pow it by black Cat then divide it by hungry tiger is only touching some other values with a different precission. This can work in a scenario but also fail again within another case

1 Like

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