POWER scalar function

The POWER function returns the result of raising the first argument to the power of the second argument.

Read syntax diagramSkip visual syntax diagramPOWER(expression1, expression2)

The schema is SYSIBM. (The SYSFUN version of the POWER function continues to be available.)

expression1
An expression that returns a value of any built-in numeric data type.
expression2
An expression that returns a value of any built-in numeric data type.

If the value of expression1 is equal to zero, then expression2 must be greater than or equal to zero. If both arguments are 0, the result is 1. If the value of expression1 is less than zero, then expression2 must be an integer value.

The result of the function is:
  • INTEGER if both arguments are INTEGER or SMALLINT
  • BIGINT if one argument is BIGINT and the other argument is BIGINT, INTEGER or SMALLINT
  • DECFLOAT(34) if one of the arguments is decimal floating-point. If either argument is a DECFLOAT and one of the following statements is true, the result is NAN and an invalid operation condition:
    • Both arguments are zero
    • The second argument has a nonzero fractional part
    • The second argument has more than 9 digits
    • The second argument is INFINITY
  • DOUBLE otherwise
If the argument is a special decimal floating-point value, the rules for general arithmetic operations for decimal floating-point apply. See General arithmetic operation rules for decimal floating-point in Expressions.

The result can be null; if any argument is null, the result is the null value.

Example

Assume that the host variable HPOWER is an integer with a value of 3.
   VALUES POWER(2,:HPOWER)
Returns the value 8.