public inbox for [email protected]
help / color / mirror / Atom feedFrom: PG Doc comments form <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Incomplete or misleading explanation of the data types for mathematical operators
Date: Wed, 29 Jan 2020 19:35:18 +0000
Message-ID: <[email protected]> (raw)
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.
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Incomplete or misleading explanation of the data types for mathematical operators
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox