Arithmetic exponentiation operator ^

Last updated: 2026-11-04

Arithmetic exponentiation operator ^

The exponentiation operator ^ raises the left operand to the power of the right operand and is equivalent to the power() function. It accepts fractional exponents, so 9 ^ 0.5 is 3. Integer operands take the double precision path while numeric operands keep exact decimal semantics. A NULL operand yields a NULL result.

Kindoperator
Example LanguageSQL

📝 Syntax

a ^ b

Precedence: `^` binds tighter than `* / %` but looser than unary `+ -` (hence `-2^2` is 4). It is left-associative at its own level, so `2 ^ 3 ^ 2` is (2^3)^2 = 64, not 2^(3^2) = 512. Parenthesise `2 ^ (3 ^ 2)` for right-associative grouping.

⚙️ Parameters

aThe base; if NULL the result is NULL.
bThe exponent, integer or fractional; if NULL the result is NULL.

Returns:double precision for integer operands or numeric for numeric operands; NULL if either operand is NULL.

▶ Example

Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.

Output:

SELECT id, base ^ exponent AS power, power(base, exponent) AS power_fn FROM t_pow ORDER BY id
id |              power |           power_fn
---+--------------------+-------------------
 1 | 1024.0000000000000 | 1024.0000000000000
 2 | 3.0000000000000000 | 3.0000000000000000
 3 |               NULL |               NULL
(3 rows)

SELECT base ^ exponent IS NULL AS null_is_absent FROM t_pow WHERE id = 3
null_is_absent
--------------
true          
(1 row)

📌 Key Points

More case studies coming soon.

📚 Related Reference

❓ FAQ

QWhat is 2 ^ 3 ^ 2?
A64. PostgreSQL evaluates ^ left-associatively: 2^3 is 8, then 8^2 is 64. Write `2 ^ (3 ^ 2)` for 512.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏