EXP function Returns the result of raising a number to a power. The number is called the base and the power is called the exponent. Syntax EXP ( base , exponent ) base A constant, field name, variable name, or expression that evaluates to a numeric value. exponent A numeric expression. Example This procedure calculates how much a principal amount invested at a given compounded annual interest rate grows over a specified number of years: r-exp.p DEFINE VARIABLE principal AS DECIMAL NO-UNDO FORMAT "->>>,>>9.99" LABEL "Amt Invested". DEFINE VARIABLE rate AS INTEGER NO-UNDO FORMAT "->9" LABEL "Interest %". DEFINE VARIABLE num-yrs AS INTEGER NO-UNDO FORMAT ">>9" LABEL "Number of Years". DEFINE VARIABLE final-amt AS DECIMAL NO-UNDO FORMAT "->>>,>>>,>>>,>>>,>>>,>>9.99" LABEL "Final Amount". REPEAT: UPDATE principal rate num-yrs. final-amt = principal * EXP(1 + rate / 100,num-yrs). DISPLAY final-amt. END. Notes After converting the base and exponent to the floating-point format, the EXP function uses standard system library routines. On some machines, these routines do not handle large numbers well and might cause your terminal to hang. Also, because the calculations are done in floating-point arithmetic, full decimal precision is not possible beyond 1-12 significant digits on most machines. The EXP function is precise to approximately 10 decimal points.
EXP ( base , exponent )
DEFINE VARIABLE principal AS DECIMAL NO-UNDO FORMAT "->>>,>>9.99"
LABEL "Amt Invested".
DEFINE VARIABLE rate AS INTEGER NO-UNDO FORMAT "->9"
LABEL "Interest %".
DEFINE VARIABLE num-yrs AS INTEGER NO-UNDO FORMAT ">>9"
LABEL "Number of Years".
DEFINE VARIABLE final-amt AS DECIMAL NO-UNDO FORMAT
"->>>,>>>,>>>,>>>,>>>,>>9.99" LABEL "Final Amount".
REPEAT:
UPDATE principal rate num-yrs.
final-amt = principal * EXP(1 + rate / 100,num-yrs).
DISPLAY final-amt.
END.