119
Views
2
Comments
Solved
Rounf to 1 up
Question

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.

2024-11-07 03-28-42
Stuart Harris
Champion
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.

2024-11-07 03-28-42
Stuart Harris
Champion

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.

  

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.