Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jA2jr-0005r5-3P for pgsql-docs@arkaria.postgresql.org; Fri, 06 Mar 2020 02:29:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jA2jp-0004hA-1T for pgsql-docs@arkaria.postgresql.org; Fri, 06 Mar 2020 02:29:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jA2jo-0004h2-Pr for pgsql-docs@lists.postgresql.org; Fri, 06 Mar 2020 02:29:20 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jA2jh-0006hn-N0 for pgsql-docs@lists.postgresql.org; Fri, 06 Mar 2020 02:29:20 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1jA2jg-0007lZ-E6; Thu, 05 Mar 2020 21:29:12 -0500 Date: Thu, 5 Mar 2020 21:29:12 -0500 From: Bruce Momjian To: sergei.agalakov@gmail.com, pgsql-docs@lists.postgresql.org Subject: Re: Incomplete or misleading explanation of the data types for mathematical operators Message-ID: <20200306022912.GB10548@momjian.us> References: <158032651854.19851.16261832706661813796@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <158032651854.19851.16261832706661813796@wrigleys.postgresql.org> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 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 +