CRE Programmer's Guide

Math Functions
Common Run-Time Environment (CRE) Programmer’s Guide528146-004
7-16
Power2
Considerations
The Power functions cause a fault if:
base = 0 and exponent is less than or equal to 0
base < 0 and exponent has a floating-point type
An intermediate calculation causes an arithmetic overflow
Example
INT i, j, k;
i := 2;
j := 3;
k := RTL_Power_Int16_to_Int16_(i, j); ! k gets 8
Power2
The Power2 functions multiply a number by an integral power of 2. These functions are
not available in the native CRE library.
base
is the number to multiply by.
exponent
is an integral power of 2.
Return Value
The Power2 functions return
base * 2
exponent
Considerations
An arithmetic fault occurs if an overflow or underflow occurs in an intermediate
calculation.
Example
INT i;
REAL(64) r, s;
r := 7.0L0;
REAL(64) PROC { CRE_Power2_Real64_ } ( base, exponent );
{ RTL_Power2_Real64_ }
REAL(64) base; ! in
INT exponent; ! in TNS
only