Re: Incomplete or misleading explanation of the data types for mathematical operators

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: sergei(dot)agalakov(at)gmail(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Incomplete or misleading explanation of the data types for mathematical operators
Date: 2020-03-06 02:29:12
Message-ID: 20200306022912.GB10548@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Wed, Jan 29, 2020 at 07:35:18PM +0000, PG Doc comments form wrote:
> 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.

Uh, how does this relate to bitwise operators? Why would we mention
type changes for things like exponentiation in the bitwise operator
documentation section?

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EnterpriseDB https://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Sergei Agalakov 2020-03-06 03:03:19 Re: Incomplete or misleading explanation of the data types for mathematical operators
Previous Message Daniel Gustafsson 2020-03-05 09:24:36 Re: Minor error