|
|||||||||
| Related Syntax | |||||||||
| operator | ** (power operator) | ||||||||
Return type: OMX The BCD or floating point number raised to the power "y", or the integer, string, or numeric-literal raised to the power "y". The first argument must be greater than 0 if the second argument is either equal to or less than zero, or not an integer.
Returns:
Syntax
numeric-expression ** numeric-expression
You can use the ** operator to raise a number to any given power.
To raise a BCD number to a power, you must include the ombcd.xin file in your program. To raise a floating point number, include the omfloat.xin file.
The following code shows how to use ** to calculate the future value of a single amount, expressed by the equation:
BCD Example:
include "ombcd.xin"
process
local bcd Principal initial {1000}
local bcd InterestRate initial {0.09}
local bcd Time initial {3}
local bcd FutureValue
local bcd RoundValue
set FutureValue to Principal * (1 + InterestRate) ** Time
set RoundValue to round FutureValue bankers-nearest bcd 0.01
output "future amount is " || "d" % RoundValue || "%n"
Floating Point Example:
include "omfloat.xin"
process
local float Principal initial {1000}
local float InterestRate initial {0.09}
local float Time initial {3}
local float FutureValue
local float RoundValue
set FutureValue to Principal * (1 + InterestRate) ** Time
set RoundValue to round FutureValue by 0.01
output "future amount is " || "d" % RoundValue || "%n"
If the principal is $1000, the interest rate 9 percent, and the time 3 years, the result would be a future amount of $1295.03.
|
Related Syntax sqrt exp ln log10 |
| ---- |