How can I implement rounding to round a number up to the nearest hundred value? When attempting to use the rounding function, a definition of round (99,950.00, -2) returns 10,000.00 not 100,000.00.
Is this working as designed? How do I define this to round to the nearest hundred value?
It is working as designed. The index or second number has to be greater than or equal to zero. The system function round(number,number) is defined as "Round to a specified number of decimal places" although it does not specify that the index (which is the second number) must be greater than or equal to 0.
This round system function, available in Expression Manager, is making use of math.round() from 'math' C library.
For example, by defining round(12.4567, n) the system will use the following calculation:
If n = 2, then:
Since the index (2nd number from round(number,number)) cannot be a negative integer, the following example can be implemented to round to the nearest hundred value.
The same implementation can be found from the business function B0000605 - MathNumericRoundScientific.
Parameters | Alias | Dir | Implementation |
---|---|---|---|
mnNumberOfDecimals (15 [2]) | MATH01 | IN | The value which is greater than or equal to <zero> |
mnUnroundedMathNumericValue (15 [2]) | MATH01 | IN | Value to round |
mnRoundedMathNumericValue (15 [2]) | MATH01 | OUT | Rounded value |
szRoundedStringValue (30) | DL40 | OUT | Return value in String |
cErrorCode (1) | ERRC | OUT | Hard Error 2 if input mnNumberOfDecimals is negative value |