Mathematical Functions and Operators

Started by PG Bug reporting formover 1 year ago2 messagesdocs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/16/functions-math.html
Description:

Typically, exponentiation (which is represented here by ^) is a
right-associative operation. This means that the expression 2 ^ 3 ^ 3 should
be interpreted as
2 ^ (3 ^ 3) rather than (2 ^ 3) ^ 3.

Correct Interpretation (right-associative):
2 ^ 3 ^ 3 is interpreted as 2 ^ (3 ^ 3), which equals 2 ^ 27 = 134217728.
However, the example provided assumes left-associative behavior:

Incorrect Interpretation (left-associative):
2 ^ 3 ^ 3 is incorrectly interpreted as (2 ^ 3) ^ 3 = 512.

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: PG Bug reporting form (#1)
Re: Mathematical Functions and Operators

On Saturday, September 7, 2024, PG Doc comments form <noreply@postgresql.org>
wrote:

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/16/functions-math.html
Description:

Typically, exponentiation (which is represented here by ^) is a
right-associative operation.

We have documented our operator precedence decisions:

https://www.postgresql.org/docs/16/sql-syntax-lexical.html#SQL-PRECEDENCE

David J.