POW

Raise a base to the given exponent.

Category: mathReturns: DOUBLEDialect: Standard

Syntax

POW(base, exponent)

Description

## Overview Returns the base raised to the given exponent. POW is the general-purpose exponentiation primitive: squaring, cubing, extracting roots, computing compound interest factors, and evaluating polynomial features all funnel through POW. POW is equivalent to POWER; the two names are interchangeable. For integer-power special cases (squaring, cubing), the engine may optimize internally, but the result type is always DOUBLE for safety across fractional exponents. ## Behavior - Accepts any finite DOUBLE for both arguments. - Returns a DOUBLE. - Returns NULL if either argument is NULL. - POW(x, 0) returns 1 for any x (including 0 in most engines, although this is mathematically a convention). - POW(0, positive_exponent) returns 0. - POW(0, negative_exponent) is mathematically undefined and typically returns NULL or positive infinity. - POW of a negative base with a non-integer exponent returns NaN or NULL because the real cube-root-style generalization does not apply. ## Numeric precision - Uses the IEEE 754 double-precision pow routine. - Accumulates more rounding error than a native multiplication chain for integer exponents; for squaring, use x * x instead of POW(x, 2) in tight numeric loops. - Overflows to infinity for very large results (for example, POW(2, 1024)) and underflows to 0 for very small results. - Fractional exponents that are not exactly representable in DOUBLE (such as 1.0/3.0) produce small rounding residues in the output. ## Compatibility - Conforms to the SQL standard scalar function POWER. POW is the shorthand. - Matches typical mathematical library implementations.

Parameters

NameTypeDescription
baseSpecifies the base value. Accepts any finite DOUBLE. Negative bases with non-integer exponents are mathematically complex and typically return NaN or NULL.
exponentSpecifies the exponent. Accepts any finite DOUBLE, including negative and fractional values. Very large magnitudes may cause overflow or underflow.

Examples

-- Basic literal: 2 raised to the 10th power
SELECT POW(2, 10);
-- Result: 1024.0
-- Square root via exponent 0.5
SELECT POW(9, 0.5);
-- Result: 3.0
-- Negative exponent yields reciprocal
SELECT POW(2, -3);
-- Result: 0.125
-- Any value raised to 0 is 1
SELECT POW(42, 0);
-- Result: 1.0
-- Edge case: 0 to a negative power is mathematically undefined
SELECT POW(0, -1);
-- Result: NULL or Infinity depending on engine
-- Negative base with integer exponent is well-defined
SELECT POW(-2, 3);
-- Result: -8.0

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →