Caché ObjectScript Reference
$ZPOWER
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   
Search:    

Returns the value of a number raised to a specified power.
Synopsis
$ZPOWER(num,exponent)
Parameters
num The number to be raised to a power.
exponent The exponent.
Description
$ZPOWER returns the value of the num parameter raised to the nth power.
This function performs the same operation as the Exponentiation operator (**). For details on valid parameter values and the value returned for specific combinations of parameter values, see Exponentiation Operator in the “Operators and Expressions” chapter of Using Caché ObjectScript.
Parameters
num
The number to be raised to a power. It can be integer or floating point, negative, positive, or zero. It can be a standard Caché number or an IEEE double-precision binary floating-point number (a $DOUBLE number). It can be specified as a value, a variable, or an expression.
If you specify num as a quoted string, the string is parsed as a number, as described in Strings as Numbers in the “Data Types and Values” chapter of Using Caché ObjectScript. The null string ("") and nonnumeric strings evaluate to zero.
exponent
The exponent is a number that can be integer or floating point, negative, positive, or zero. It can be a standard Caché number or an IEEE double-precision binary floating-point number (a $DOUBLE number). It can be specified as a numeric or string value, a variable, or an expression.
If you specify exponent as a quoted string, the string is parsed as a number, as described in Strings as Numbers in the “Data Types and Values” chapter of Using Caché ObjectScript. The null string ("") and nonnumeric strings evaluate to zero.
The following combinations of num and exponent result in an error:
For further details on valid parameter values and the value returned for specific combinations of parameter values, see Exponentiation Operator in the “Operators and Expressions” chapter of Using Caché ObjectScript.
Examples
The following example raises 2 to the first ten powers:
  SET x=0
  WHILE x < 10 {
    SET rtn=$ZPOWER(2,x)
    WRITE !,"The ",x," power of 2=",rtn
    SET x=x+1 }
 
See Also