|
|||||
|
||||||
Related Topics | Other Library Functions |
operator |
** (power) |
Library: Floating point number support (OMFLOAT)
Import: omfloat.xmd Library: Binary coded decimal (BCD) numbers (OMBCD) Import: ombcd.xmd |
Return type: BCD or float Returns: 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. |
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 import the ombcd.xmd file in your program. To raise a floating point number, import the omfloat.xmd file.
The following code shows how to use **
to calculate the future value of a single amount, expressed by the equation:
import "ombcd.xmd" unprefixed 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 0.01 output "future amount is " || "d" % RoundValue || "%n"
import "omfloat.xmd" unprefixed 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 Topics |
Other Library Functions |
Copyright © Stilo International plc, 1988-2010.