^ [exponentiation]

All functions > MATH > ^ [exponentiation]

Raises a number to a power (integer or floating-point operands of the same type).

Syntax

base ^ exponent  ·  base ** exponent  ·  POW(base, exponent)

Function form

Power: Base raised to the power of exponent

POW(base: T, exponent: T) → T
sql
ParameterTypeRequiredDescription
baseTYesThe base number
exponentTYesThe exponent

With:

  • T : Any numeric type

  • Same-type numeric pairs, or a floating/DECIMAL base with an integer exponent

  • POW(x, 0) = 1 for any non-zero x

  • POW(0, y) = 0 for positive y

  • Returns NULL if either input is NULL

  • Alias: POWER

Aliases: POWER

Notes

  • Same-type numeric pairs, or a floating/DECIMAL base with an integer exponent
  • POW(x, 0) is 1 for any non-zero x; POW(0, y) is 0 for positive y
  • Returns NULL if either input is NULL
  • You can write the operator as ^ or **

Examples

^ and ** — integers

FeatureQL
RETURN
    -- Caret exponentiation
    f1 := 2 ^ 3,
    -- Double-asterisk exponentiation
    f2 := 3 ^ 2
;
Result
f1 BIGINTf2 BIGINT
89

^ and ** — floating-point

FeatureQL
RETURN
    -- Negative exponent
    f1 := 2.0e0 ^ (-2.0e0),
    -- Fractional exponent
    f2 := 4.0e0 ^ 0.5e0
;
Result
f1 DECIMALf2 DECIMAL
0.252.0

POW(...)

FeatureQL
RETURN
    -- Function call
    f1 := POW(2, 3)
;
Result
f1 BIGINT
8

.POW(...) — chained

FeatureQL
RETURN
    -- Integer literal: parenthesize for `.POW` on BIGINT
    f1 := (2).POW(3),
    -- DOUBLE operands: chain without extra parentheses (same-type floating-point power)
    f2 := 2e0.POW(3e0)
;
Result
f1 BIGINTf2 DECIMAL
88.0

POW — Edge cases

FeatureQL
RETURN
    -- Square
    f1 := POW(5, 2),
    -- Exponent zero
    f2 := POW(10, 0),
    -- Negative exponent (DOUBLE)
    f3 := POW(2.0e0, -2.0e0),
    -- Fractional exponent (DOUBLE)
    f4 := POW(4.0e0, 0.5e0)
;
Result
f1 BIGINTf2 BIGINTf3 DECIMALf4 DECIMAL
2510.252.0