3
Followers
2
Likes

# Round to nearest in financial calculations

Builtin & User functions

In expressions for financial calculations e.g. loan payments, interest payable etc. it would be useful to have a Rounding function that rounds a number to a specified number of digits. Where the round method always rounds to the "nearest" i.e.

Round(2.5,0) = 3 ... not "2" as per the Outsystems round function which rounds to the nearest even number!

Round(3.5,0) = 4

Round(2.4445,2) = 2.45

Created on 20 Dec 2017

Pretty sure this is how it already works, here is the help text from the built-in Round function:

J.Ja

Hi Justin, rounding of numbers is often an issue on many platforms.

What we have found with Outsystems is that in client-side and server-side expressions, the current Round function will round incorrectly on the ".5" boundary. The method used by Outsystems is to round to the nearest "even" integer i.e. for the example "Round(2.5)", this will result in 2, when it should be 3. This is not what I would expect and we have found test cases resulting in erroneous values caused by rounding when we have a '.5' boundary condition.

To fix the problem in the short term we implemented our own rounding method, but it is having an effect in more and more places as we develop more complex financial calculations.

Hope that explains our situation.

Regards, John.

I see.

I would be *certain* that the Round function is just calling the underlying .NET or Java Math.Round() function, so any behavior outside of that is going to be - unfortunately - your own business logic I suspect. :(

That said, it would be fantastic if you could look in the Forge for some of the existing math libraries (I maintain one with all of the missing trig functions, for example) and add your implementation there so the rest of us can benefit from your improvements too!

J.Ja

Yup,

.Net Rounding is using the Banker's rounding, so 7.5 and 8.5 will round to 8

views
548
Followers
3