From: | PG Doc comments form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-docs(at)lists(dot)postgresql(dot)org |
Cc: | sergei(dot)agalakov(at)gmail(dot)com |
Subject: | Incomplete or misleading explanation of the data types for mathematical operators |
Date: | 2020-01-29 19:35:18 |
Message-ID: | 158032651854.19851.16261832706661813796@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs |
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/12/functions-math.html
Description:
"The bitwise operators work only on integral data types, whereas the others
are available for all numeric data types. "
Many math operators silently convert integral data types to double for
calculations, so the result will not be the same data type as what was
provided.
select pg_typeof(10^2::bigint),pg_typeof(10^2::numeric)
select pg_typeof(|/25::int), pg_typeof(|/25::numeric)
select pg_typeof(10*10::bigint), pg_typeof(10*10::numeric)
Multiplication preserves data type, exponentiation silently converts bigint
to double, but preserves numeric data type, square root silently converts
both int and numeric types to double.
The best would be to explain this behaivior of operators like it was done
for mathematical functions.
From | Date | Subject | |
---|---|---|---|
Next Message | PG Doc comments form | 2020-01-30 01:26:49 | pg_dump documentation page |
Previous Message | Magnus Hagander | 2020-01-29 08:57:12 | Re: Typo |