ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Numeric Calculations → Numerical Functions
ipow - Integer Power Function
Other versions:
7.31 | 7.40 | 7.54
Syntax
... ipow( base = arg exp = n ) ...
Effect
This function raises the argument arg
passed to base
to the exponent n
passed to exp
. The arguments arg
and n
are
numeric expression positions. Any
numeric data object
can be specified for arg
. n
expects the type i
and exponents of other types are
converted to i
.
If the argument arg
has the value 0, the value of the exponent n
must be greater than or equal to 0.
The function ipow
is overloaded with the effect that the return value can have different numeric types.
- With the exception of an
arithmetic expression, the data type of the argument
arg
determines the data type of the return value.
- Within an arithmetic expression, the argument
arg
contributes to the calculation type of the entire expression and the function is calculated using the calculation type.
- If the argument
arg
is a numeric expression,ipow
works like an arithmetic operator and the function is handled in its operand position like an arithmetic expression.
This function can be specified in general and
numeric expression positions. The calculation type is determined from the argument arg
in the same way as with the other
numeric functions. The argument n
does not have any effect on the data type of the return value.
Notes
- The power function
ipow
can replacearg ** n
calculations, if the calculation type f is to be avoided. This makes sense if the typef
is not precise enough.
- In many cases, the power function
ipow
displays better performance than using the arithmetic operator**
.
Example
The results are 1.4399999999999999 for **
and
1.4400 for ipow
. The result of ipow
is more precise.
cl_demo_output=>display( |** : { '1.2' ** 2 } \n| &&
|ipow: { ipow( base = '1.2' exp = 2 ) }| ).