# POWER or POW

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

expression-1
An expression that returns a value of any built-in numeric, character-string, or graphic-string data type.1 A string argument is cast to double-precision floating point before evaluating the function. For more information about converting strings to double-precision floating point, see DOUBLE_PRECISION or DOUBLE.
expression-2
An expression that returns a value of any built-in numeric data type. If the value of expression-1 is equal to zero, then expression-2 must be greater than or equal to zero. If the value of expression-1 is less than zero, then expression-2 must be an integer value.

If the data type of the argument is decimal floating-point, the data type of the result is DECFLOAT(34). Otherwise, the result of the function is a double-precision floating-point number. If both arguments are 0, the result is 1. If an argument can be null, the result can be null; if an argument is null, the result is the null value.

## Note

Results involving DECFLOAT special values: If either argument is decimal floating-point, both arguments are converted to DECFLOAT(34). For decimal floating-point values the special values are treated as follows:
• If either argument is NaN or -NaN, NaN is returned.2
• POWER®(Infinity, any valid second argument) returns Infinity.
• POWER(-Infinity, any valid odd integer value) returns -Infinity.
• POWER(-Infinity, any valid even integer value) returns Infinity.
• POWER(0,Infinity) returns 0.
• POWER(1,Infinity) returns 1.
• POWER(any number greater than 1,Infinity) returns Infinity.
• POWER(any number greater than 0 and less than 1,Infinity) returns 0.
• POWER(any number less than 0,Infinity) returns NaN. 2
• If either argument is sNaN or -sNaN, a warning or error is returned. 2

## Example

• Assume the host variable HPOWER is an integer with value 3.
``````  SELECT POWER(2,:HPOWER)
FROM SYSIBM.SYSDUMMY1``````
Returns the value 8.
1 The result of the POWER function is exactly the same as the result of exponentiation: expression-1 ** expression-2.
2 If *YES is specified for the SQL_DECFLOAT_WARNINGS query option, NaN is returned with a warning