Hi,


I'm in a server action and tring following.

x1= Round(x,4)

x2= Round (x1,3)

x3= Round(x2,2)


Thing is I need to round if 5 to plus 1, how to do that? as in server action it rounds to nearest even number.

Solution

Hello Abeer,

There is a CommonMath extension on the Forge that is very old that has a single function to perform rounding like this.

The quickest and easiest way would be to create an Extension and call the .NET Math.Round() function with the MidpointRounding.AwayFromZero option.

I am surprised there isn't an extension on the forge with lots of similar Math type actions to be honest.

Solution

Oh, using the built in features, there is actually a way to implement this rounding, but it is a bit clunky, and I don't recommend it. But still, it is possible to do.

All of the local variables and parameters here are decimals, except for Digits which is an integer.