What this document contains:
- Rounding/Grouping operators
- Grouping an operation
- Grouping an operation where one factor holds decimals
- More than one rounding operator
When a formula is applied it is evaluated from left to right and mathematical operator precedence does not apply. The syntaxs used to define the formula is what will dictate how values will be calculated. This means that operators * and / will not have higher precedence than + or - IF you do not declare that a certain precedence is desired by use of Rounding/grouping operators.
Mathematically speaking the expected result of expression 2 + 3 * 5 would be equal to 17 as * has a higher precedence than +. The expression is calculated as: 2 + (3*5) = 2 + 15 = 17
However, the expression above in the item classification formula definition will be evaluated from left to right if nothing else is indicated. Hence, the result of expression 2 + 3 * 5 would be equal to 25 (2 + 3= 5 * 5 = 25).
These examples are very simple as they are only used to exemplify how a formula definition where only constants are included will be out of context. The use of parenthesis for some formulas might be advisable, mainly those more complex used for calculation of conversion factors. The use of parenthesis to group operations is needed to get the correct result. They will also add readability to a formula that otherwise would be too complex to read.
IF a certain precedence is desired, rounding/grouping operators ( )RN can be used. For example, if you want a certain group of operations to take place before they are included in the formula main calculation then ( )RN can be used to group these operations. For example:
|2 + (3*5)R0|
In this case, the result of the formula will be 17 as you are defining that operation 3*5 shall take place before it is added to constant 2. Since integer constants are used in this example, the rounding is set to 0 decimals.
On the other hand in a real environment where constants and variables (characteristics or alternatively pricing special values) are combined within a formula, and one or more operators of an operation grouped by rounding/grouping operators ()R hold decimals, the grouped operation can/should be set to round the result to the max number of decimals (9). This is the case if operator ( )R is being used to group an operation rather than to round the result of it as it is the case in these examples.
If one of the factor holds decimals, you should set the rounding ()RN to 9 to keep the maximum number of decimals. This will ensure that the end result is not affected, but the order of operations is as you want it. If you want to calculate the expression 2+3*5,53 in order of operation the formula would be written as:
You can have more than one rounding operator in the same expression. The example below is given to exemplify how the rounding operators can be combined.
|((BOXLENGTH * BOXWIDTH)R6 * (BOXPCS * 0,001)R2)R0|
Up to 9 rounding operators ( )R can be combined within a formula definition.