abs, sign, ceil, floor, trunc, frac - Numeric Functions
The following table shows the general numeric functions for a single unnamed argument with any numeric data type. These functions are overloaded with the effect that the return value can have different numeric types.
... func( arg ) ...
The argument of a general numeric function must be an individual data object outside an arithmetic expression, and can itself be a numeric expression within an arithmetic expression.
Effect of the general numeric functions.
|Function func||Return value|
||Absolute value of argument
||Sign of argument
||Smallest integer that is not less than the value of the argument
||Largest integer that is not greater than the value of the argument
||Value of the integer part of the argument
||Value of the decimalplaces of the argument
The following applies with regard to the data type of the return value:
- With the exception of an arithmetic expression, the data type of the argument determines the data type of the return value.
- Within an arithmetic expression, the argument of the function contributes to the calculation type of the entire expression and the function is calculated using the calculation type. If the argument itself is an arithmetic expression, its operands contribute to the entire calculation type and the argument is also calculated with this type.
- If the argument
argis a numeric expression, the function works like an arithmetic operator and it is handled in its operand position like an arithmetic expression.
If the argument of a numeric function outside of an arithmetic expression does not have a numeric data
f, its data type determines the type of return value as follows:
utclongis not allowed
Before the calculation of the function, the argument is converted into the respective type..
- The time stamp type
utclongcannot be converted implicitly to a numeric type, and therefore cannot be specified directly as an argument.
- The functions described here are some of the functions that can be used in the obsolete extended functional operand positions, even if their argument is a single data object.
The following assertion should always be correct.
DATA pack TYPE p LENGTH 8 DECIMALS 4 VALUE '-1234.5678'. cl_demo_input=>request( CHANGING field = pack ). ASSERT pack = trunc( pack ) + frac( pack ).