Controlling rounding in financial functions
Unlike other numeric operations in Analytics, financial functions are evaluated using floating-point arithmetic.
Floating-point arithmetic affects your calculations in two ways:
-
Any function that returns an amount will do so to two decimal places, for example, 1250.00
-
Any function that returns an interest rate will do so to eight decimal places, for example, 0.01676584 or 1.676584%
In financial functions, you often divide interest rates by constants such as 12 or 365, to create monthly or daily interest rates. For example, 0.08/365 gets the daily interest factor based on 8% per annum. The normal Analytics rules for division would result in significant rounding errors in most situations. For example, 0.08/365 will result in an interest rate of 0.00, instead of the actual rate of 0.000219178. For this reason, the normal division rules are suspended when evaluating interest rate parameters.
When the interest rate parameter in a financial function is the division of two quantities (for example, 0.08/365), then the two quantities are evaluated separately. They are then divided, maintaining the full precision of the result. Each of the two sides are still evaluated using the standard Analytics rules for rounding, so in the case of very complex calculations, this solution may still not provide total protection from rounding errors.
When the interest rate is neither a specific rate, nor the division of two simple quantities, (for example, 08/1/365) then a warning message is included in the log (and displayed in an alert dialog, if not in script mode) warning that rounding may have affected the interest rate calculation. When this occurs, you should ensure that the result returned has not been rounded excessively.
When the interest rate is calculated in a computed field, Analytics cannot determine whether the rate has been rounded, so you must ensure that the result is correct.