ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Numeric Calculations → Numerical Functions → Examples of numerical functions
Integer Power Function ipow
This example demonstrates the integer power function ipow
.
Other versions:
7.31 | 7.40 | 7.54
Source Code
DATA n TYPE i.
DATA arg1 TYPE p DECIMALS 1.
DATA arg2 TYPE i.
<span class="blue">* DATA arg2 TYPE int8.</span>
n = 2.
arg1 = `1.2`.
DATA(out) = cl_demo_output=>new(
)->write( |** : { arg1 ** n }|
)->write( |ipow: { ipow( base = arg1 exp = n ) }| ).
cl_demo_output=>line( ).
n = 30.
<span class="blue">* n = 62.</span>
arg2 = 2.
out->write( |** : { arg2 ** n }|
)->write( |ipow: { ipow( base = arg2 exp = n ) }| ).
out->display( ).
Description
The program demonstrates that the integer power function ipow
can be used
to achieve more precise results than with the arithmetic operator . In the cases shown here, the operator
produces the
calculation type
f. If
ipow
is used, the calculation type is determined by the arguments arg1
and arg2
.