PWR Function
Calculates a number raised to a power.
Syntax
PWR(expression1, expression2)
expression1^expression2
Syntax Elements
expression1, expression2
any DataBasic expression that evaluates to a number.
Operation
PWR computes the value of expression1 to the power of expression2.
Negative values can be raised to negative or positive integer values, but a negative value raised to a non-integer value is undefined in DataBasic.
If you try to raise a negative number to a non-integer value, a warning message is displayed and a value of zero is returned.
If there is no PRECISION statement in the program, the value is returned rounded to the nearest four decimal places. Otherwise, the number of decimal places returned is as specified by the PRECISION statement. In each case, the significant decimal places returned are the result of rounding. However, only up to five places are significant: if the PRECISION statement specifies a precision greater than five, trailing zeroes are appended to the five significant places so as to return the numbers of places specified.
Examples
PRINT PWR(2,5)
Prints the value 32 (2 to the fifth power).
X = -3
Y = -6
Z = PWR(X,Y)
Assigns the value 0.0014 to variable Z.
F = 4
G = 2^F
Assigns the value 16 to variable G (2 to the fourth).